I have the below UITableViewController attached as a searchResultsController:
import UIKit
import MapKit
class LocationSearchTable : UITableViewController {
I had similar issue! After several minutes of debugging, I realized I didn't inherit the
UITableViewDelegate, UITableViewDataSource
on my ViewController.
The error
failed to obtain a cell from its dataSource
occurs because the signature of cellForRowAtIndexPath
is wrong. In Swift 3 it's
(override) func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
and use the convenience method
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for:indexPath)
which returns always a valid non-optional cell.
PS: You don't need to set datasource and delegate to self
because UITableViewController
does that implicitly