Checklists: Fatal Error Unexpectedly found nil when unwrapping an Optional value

On page 235 of the latest version of the iOS apprentice, the following line:

let label = cell.viewWithTag(1000) as! UILabel

Causes a runtime error after a successful build.

“Fatal error: Unexpectedly found nil while unwrapping an Optional Value”

Any pointers on how to go about fixing this error? Thanks for any and all help.

Kurt

This usually happens either because you didn’t set the correct tag (1000) for the label, or you set the tag on the wrong item (the table view cell instead of the label). Please check for both of these issues and you should hopefully be able to fix the crash.

That was exactly the problem. I guess I should read the instructions more carefully next time, whoops.

This topic was automatically closed after 166 days. New replies are no longer allowed.