Could not dequeue a view of kind:

I am learning Xcode/Swift from Ahmad Sahar's book and I have an exception error:
Code Block Exception NSException * "could not dequeue a view of kind: UICollectionElementKindCell with identifier restaurantCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" 0x00006000002d06c0
name __NSCFConstantString * "NSInternalInconsistencyException" 0x00000001c3059170
reason __NSCFString * "could not dequeue a view of kind: UICollectionElementKindCell with identifier restaurantCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" 0x00006000037a09c0
userInfo void * NULL 0x0000000000000000
reserved __NSDictionaryM * 2 key/value pairs 0x0000600000cf0480

The previous action that I did was to Ctrl + Drag from the exploreCell in the ExploreViewController Scene to the RestaurantListViewController Scene, creating a 'Show' Segue.
As I am a beginner I am not sure what the error is telling me?
Can someone help and show me where I am going wrong?
Answered by Rocky48 in 670897022
Can't spell spelt Restaurant as resturant?
Definitely need a new pair of glasses!

It would be much easier if we could get the whole code of the class…

But error:
reason __NSCFString * "could not dequeue a view of kind: UICollectionElementKindCell with identifier restaurantCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard" 0x00006000037a09c0

tells that :
  • you have created a nib file for the cell (.xib): exact ?

  • if so, you need to register the cell nib file, with code like (assuming the cell file is "restaurantCell.xib" and that restaurantCell class has the same name restaurantCell :

Code Block
let nib = UINib(nibName: veHeaderCell, bundle: nil)
collectionView.register(nib, forCellReuseIdentifier: "restaurantCell") // I don't know who is the collectionView

If the cell is defined directly in the CollectionView in Storyboard, as Custom cell, then you need to connect the cell to its class definition.
Accepted Answer
Can't spell spelt Restaurant as resturant?
Definitely need a new pair of glasses!

Thanks for the feedback.

But not showing the code in your initial post, you made it impossible to guess… and just wasted others time who tried to figure it out.

So please, next time, post the code where the error occurs.

Have a good day.
Could not dequeue a view of kind:
 
 
Q