The dequeueReusableCellWithIdentifer:forIndexPath: (introduced in iOS6) is a nice improvement, since you don't need to check if the cell is nil. (So UITableViewController works similar to UICollectionView) But yeah, annoying that this change isn't comment in the template and that the assertion/crash message isn't more helpful.
–
Jason MooreDec 4 '12 at 19:48

2

At the very least you'd think that it would default to UITableViewCell instead of imploding. Baka.
–
BadPirateJan 8 '13 at 20:23

4

@HotFudgeSunday. Not sure why you got so mad about UITableViewController. The data source concept is essentially the same as the Adapter for Android ListViews. And I would say UITableView is much much better than Android's ListView, which does not even support sections. Not even mention about dragging list items.
–
RayJan 14 '13 at 21:48

9

The last line of this answer is golden: I've been bitten more than once by using dequeueReusableCellWithIdentifier:forIndexPath: when I should've been using dequeueReusableCellWithIdentifier:.
–
eleFeb 28 '13 at 16:55

Just to add to this on a slightly different use case, I was reselecting a row in the Master view of my SplitViewController. This reselect row logic was in the viewDidLoad and moving this logic to viewDidAppear fixed it.
–
Craig ConoverApr 22 '14 at 7:06

Note - if you use an identifier other than "Cell" you'll also need to change your cellForRowAtIndexPath method to use this identifer in the following line: static NSString *CellIdentifier = @"MyCellIdentifier";
–
gamozziiOct 27 '13 at 4:53

Haha I had the identifier from a different viewController...
–
MorkromJan 26 '14 at 10:55

3

One important addition to this: The table view must have its "Content" attribute set to "Dynamic Prototypes", NOT "Static Cells"
–
Ted AveryJan 30 '14 at 0:46

I'll just add that Xcode 4.5 includes the new dequeueReusableCellWithIdentifier:forIndexPath:
in its default template code - a potential gotcha for developers expecting the older dequeueReusableCellWithIdentifier: method.

In your storyboard you should set the 'Identifier' of your prototype cell to be the same as your CellReuseIdentifier "Cell". Then you won't get that message or need to call that registerClass: function.

Gotcha! Where is the '100 upvotes'-button. This is the real solution.
–
Jojo.LecheltMar 4 '13 at 15:06

You would think that adding a new tableView into a storyboard will provide a default identifier - 'Cell' for you. It's so easily overlooked especially if you are using the so called 'free code' in tableView:cellForRowAtIndexPath!
–
ushikaMar 10 '13 at 11:20

The problem is most likely because you config custom UITableViewCell in storyboard but you do not use storyboard to instantiate your UITableViewController which uses this UITableViewCell. For example, in MainStoryboard, you have a UITableViewController subclass called MyTableViewController and have a custom dynamic UITableViewCell called MyTableViewCell with identifier id "MyCell".

I spent hours last night working out why my programmatically generated table crashed on [myTable setDataSource:self]; It was OK commenting out and popping up an empty table, but crashed every time I tried to reach the datasource;

I had the delegation set up in the h file: @interface myViewController : UIViewController

I had the data source code in my implementation and still BOOM!, crash every time! THANK YOU to "xxd" (nr 9): adding that line of code solved it for me! In fact I am launching a table from a IBAction button, so here is my full code:

FWIW, I got this same error when I forgot to set the cell identifier in the storyboard. If this is your issue then in the storyboard click the table view cell and set the cell identifier in the attributes editor. Make sure the cell identifier you set here is the same as

Corrected the error but i'm still at a loss. I'm not using a 'custom cell', just a view with a tableview embeded. I have declared the viewcontroller as delegate and datasource and made sure the cell identifier matches in file. whats going on here?????

This might seem stupid to some people but it got me. I was getting this error and the problem for me was that I was trying to use static cells but then dynamically add more stuff. If you are calling this method your cells need to be dynamic prototypes. Select the cell in storyboard and under the Attributes inspector, the very first thing says 'Content' and you should select dynamic prototypes not static.