I have been following the apple tutorial here and have come across an error:
2016-01-12 09:34:32.909 FoodTracker[1812:124509] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier MealTableViewCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
The error appears when the program is run, and the red highlighted line appears on the class line of AppDelegate.swift
These are the lines of code I believe are causing the error, as I found out through breakpoints:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "MealTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! MealTableViewCell
// Configure the cell...
let meal = meals[indexPath.row]
cell.nameLabel.text = meal.name
cell.photoImageView.image = meal.photo
cell.ratingControl.rating = meal.rating
return cell
}
I have looked around online, and a lot of answers have said to ensure that the TableCell has an identifier, however mine does and the error still pops up.
Please let me know if I need to post any more info.
Thanks in advance
This works for me..
and I'm using a different identifier, "DeviceDetailsCell"
let cellIdentifier = "DeviceDetailsCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! DeviceDetailsTableViewCell
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