János János - 1 year ago 650
iOS Question

UITableview: failed to obtain a cell from its dataSource

I get this error message:

failed to obtain a cell from its dataSource

The strange that

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

not even get called, problem is not that returned cell is nil. I put in breakpoints.
not get called.

returns value.

I do not know it is relating or not, but now I do not use
, I just have a
, and it is the
for the
. I hope it can not cause interfere. Any idea?

Answer Source

Cross check below check list:-

  • it's because you are failing to dequeue a reusable cell.
    • The problem is that your cellForRowAtIndexPath function is embedded in another function
    • when you forgot to add the UITableViewDataSource and UITableViewDelegate protocols to the ViewController declaration.

class DataViewController: UIViewController, UITableViewDataSource, UITableViewDelegate

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download