The problem is not your actor, but the cell declaration. You declared it as an optional UITableViewCell, and this declaration remains forever - and thatβs all the compiler knows.
Therefore, you must point to the customLabel dial customLabel . Instead of this:
cell.customLabel.text = "test"
You need the following:
(cell as QuestionTableViewCell).customLabel.text = "test"
You can make it easier for yourself by declaring another variable (since you know that in this particular case your cell will be QuestionTableViewCell), but as long as you only have one variable, cell , you have to constantly throw it in any class which, in your opinion, really will be. Personally, I would write something similar to avoid casting again:
if let questionText = objectAtIndexPath as? String { let qtv = tableView.dequeueReusableCellWithIdentifier("questionCell", forIndexPath: indexPath) as QuestionTableViewCell qtv.customLabel.text = "test" cell = qtv }
source share