4

Why I am getting an error like this? In my appicaction I am loading webview inside a table view.

*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6048
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource is not set'
5
  • Have you set dataSource property of your tableView? Oct 5, 2012 at 8:16
  • Yes and it is loading, but when I am scrolling to bottom of the tableview it is crashing.
    – Dev
    Oct 5, 2012 at 8:30
  • The number of rows, did you remember to do -1 on it ? Oct 5, 2012 at 11:31
  • how did you fix this issue finally?
    – flypig
    Jun 9, 2013 at 2:31
  • Can we see the code for your table view delegate / data source methods? Jun 13, 2013 at 15:02

4 Answers 4

3

In my case, it was a DatePicker throwing the error when I set it's .date property in viewDidLoad. When I moved the code to viewDidAppear, the issue gone.

This error happen only in iPhone 4s, not other later models, iPhone nor iPad.

2

It's an old issue, I know, but I ran into the same issue in iOS 11.0 and Swift 4.0.

I have a UITableViewController and I had added the tableView from this as a subview to another view. Every time I debugged the tableView the viewDidLoad was called correctly and it printed out the right values. The error occurred when the cellForRowAt ran the second time.

The solution for me was to add the whole UITableViewController as a addChildViewController to the parent view where I wanted the tableView to appear.

I know this probably don't help the OP today but there might be someone out there struggeling with an issue like this today.

1
  • I'm adding a tableview to a collectionview cell. It doesn't allow 'addChildViewController' to be called so I only set the subview. Any ideas on how to do what you're talking about for a collectionview cell?
    – mdimarca
    Mar 8, 2018 at 21:25
0

I was also encountering this issue. (Spent days to identify it.) Just now, I've solved it. I am not a hundred percent sure what has solved the problem but what I changed was to populate all my views(some custom configurations) in the viewDidLoad, instead of viewWillAppear.

Somehow something was causing a dataSource problem. I just want to suggest anyone: whatever you're doing in viewWillAppear that might be related to tableView, try it in the viewDidLoad.

-1

I guess your UITableView's data source is not set :)

More helpfully, have you checked that in your xib you have connected up the dataSource property from your tableview?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.