table view cell of custom class returning nil

ZiEiTiA

I am creating a table, and using this code to generate the cells:

let cell2:iPRoutineSpecificCell = self.routineSpecificsTable.dequeueReusableCell(withIdentifier: "Cell2") as! iPRoutineSpecificCell

The cell contains a label. When i say

cell2.label.text = "Test"
return cell2

I get the error:

fatal error: unexpectedly found nil while unwrapping an Optional value

I have this exact arrangement elsewhere in the app and it is working fine. Why is it not working this time? The only difference between the two views is that this one contains two tables. However, if i use:

cell2.textLabel?.text = "Test"

Then it works.

Any help appreciated!

Tushar Sharma

Please remove this line from viewDidLoad method if you have-:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related