When I received this error, I initially used the boilerplate code for the UITableViewController class , but the actual view controller was a UIViewController .
Source code (leading to an error) :
Note that this is due to the UIViewController in the storyboard.
class MainViewController: UITableViewController {
}
Work code (error removal) :
class MainViewController: UIViewController {
}
Remember also to reference the IBOutlet for your UITableView in your view controller and set the delegate and data source (in the Storyboard, you Ctrl + Drag from the UITableView to the yellow circle at the top of the view controller and click dataSource. Repeat this for the delegate as well).
source
share