invalid nib registered for identifier (CELLNAME) - nib must contain exactly one top level object which must be a UITableViewCell instance

Viewed 39523

Sorry for the long title, but I wanted it to be clearly seen from a google search. Also, this differs from many of the other similar questions on here as its not specifying a 'null' identifier but one that actually exists.

Essentially the problem occurs when your trying to navigate using one of the cells in a table view controller to segue to another view (Whatever that view may be).

Most people would run into this problem after gunning through the apple tutorial on the 'To-Do List' and expecting the cells to operate in the same motion regardless of their purpose. This problem is probably simplistic to most but for a beginner, its quite hard, it took me around 3 hours.

Basically the error is:

invalid nib registered for identifier (prototypeCell) - nib must contain exactly one top level object which must be a UITableViewCell instance

Where 'prototypeCell' would be whatever your cell is called. This is an exception that occurs immediately as the app is launched.

14 Answers

In my case, I had an extra ImageView inside the xib added by mistake. Removed it and everything worked perfectly.

enter image description here

This error is mainly due to some extra views that are added by mistake. Have a look in the .xib file and check for extra unwanted view added by mistake. Delete that and it will work perfect. You can check for unwanted views by this is how it looks

I solved this by setting the class name in interface builder to match the cell reuse identifier (for that class) in interface builder.

Note: I'm not saying the class and identifier have to be the same. I'm saying they need to link the corresponding view and backing model.

I dragged collection view cell from other project and got this.
'invalid nib registered for identifier (cell) - nib must contain exactly one top level object which must be a UICollectionReusableView instance' .
Then i compared the collection view cell from created my me and found reusable view missing. Hope this help.
enter image description here

It was a silly mistake on my side and I had two tableview cells which caused this error. Removed the other 'table view cell' which fixed the issue.

Related