Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard

People also ask

Could not dequeue cell with identifier?

…it means that your call to dequeueReusableCell(withIdentifier:) is failing, which is usually caused by having no prototype cells with the identifier you requested. First: check that you have a prototype cell registered.

How do you link a prototype cell to a storyboard?

Show activity on this post. From Storyboard: In Attribute Inspector set Reuse Identifier. Add your CustomCell class in your storyboard like mentioned by Jignesh Agola.

What is dequeueReusableCell in Swift?

dequeueReusableCell(withIdentifier:)Returns a reusable table-view cell object after locating it by its identifier.

How do you stop reusing cells in UITableView?

Moreover, as @Fonix suggests, using a different cell identifier for each cell of your UITableView might solve your issue while keeping using cell reuse system.


You can register a class for your UITableViewCell like this:

With Swift 3+:

self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")

With Swift 2.2:

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")

Make sure same identifier "cell" is also copied at your storyboard's UITableViewCell.

"self" is for getting the class use the class name followed by .self.


Have you set the Table Cell identifier to "Cell" in your storyboard?

Or have you set the class for the UITableViewController to your class in that scene?


This worked for me, May help you too :

Swift 4+ :

self.tableView.register(UITableViewCell.self, forCellWithReuseIdentifier: "cell")

Swift 3 :

self.tableView.register(UITableViewCell.classForKeyedArchiver(), forCellReuseIdentifier: "Cell")

Swift 2.2 :

self.tableView.registerClass(UITableViewCell.classForKeyedArchiver(), forCellReuseIdentifier: "Cell")

We have to Set Identifier property to Table View Cell as per below image,

enter image description here


I had this issue today which was solved by selecting Product -> Clean. I was so confused since my code was proper. The problem started from using command-Z too many times :)


y my case i solved this by named it in the "Identifier" property of Table View Cell:

enter image description here

Don't forgot: to declare in your Class: UITableViewDataSource

 let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell