I'm trying to display a table view inside a container view, which itself is a part of a view controller. Here's my HomeScreenViewController, which has a button that segues to the BroadcastSearchViewController.
Once I click the button, however, I'm getting the following runtime error. Why? What can I do to make this work? Do I need to switch up my design somehow?
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UITableViewController loadView] instantiated view controller with identifier
"UIViewController-OSu-KC-K41" from storyboard "Main", but didn't get a UITableView.'
Here's what my BroadcastSearchViewController looks like in Storyboard. It's presented modally from clicking the search button.
And here's what my table view controller, which is embedded in the container view, looks like:
BroadcastSearchViewController.swift
class BroadcastSearchViewController : UIViewController {
@IBOutlet weak var broadcastSearchBar: UISearchBar!
@IBOutlet weak var broadcastSearchSegmentedControl: UISegmentedControl!
override func viewDidLoad() {
super.viewDidLoad()
}
}
BroadcastSearchResultsTableViewController.swift
class BroadcastSearchResultsTableViewController : UITableViewController {
let datasource = BroadcastSearchResultsTableViewDataSource()
override func viewDidLoad() {
datasource.broadcasts = [
Broadcast(
song: Song(id: "1", title: "November Rain", artist: "Guns N' Roses"),
user: User(username: "sylphrenetic")
),
Broadcast(
song: Song(id: "2", title: "How To Disappear Completely", artist: "Radiohead"),
user: User(username: "sylphrenetic")
)
]
self.tableView.dataSource = datasource
self.tableView.reloadData()
}
}