…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.
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.
dequeueReusableCell(withIdentifier:)Returns a reusable table-view cell object after locating it by its identifier.
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,
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:
Don't forgot: to declare in your Class: UITableViewDataSource
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With