I am creating a very simple app and I am getting this error when I try to dequeue my tableview cell.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnimalCell", for: indexPath) as! AnimalTableViewCell
let animal = animals[indexPath.row]
let thisLocation = locations.randomElement()
cell.fillInTheDetails(animal: animal, location: thisLocation!)
return cell
}
I am getting an error when I call this
let cell = tableView.dequeueReusableCell(withIdentifier: "AnimalCell", for: indexPath) as! AnimalTableViewCell
The error message is as follows:
TableViewWithMap[27537:9935669] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x600001224030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key animalName.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20193ff5 objc_exception_throw + 48
2 CoreFoundation 0x00007fff20422c5b -[NSException init] + 0
3 Foundation 0x00007fff207af46c
I've already registered this TableViewcell in viewDidLoad function
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UINib(nibName: "AnimalTableViewCell", bundle: nil), forCellReuseIdentifier: "AnimalCell")