Quickly and unexpectedly found zero when expanding an optional value

I have a class:

class ListOfEventsController: UIViewController, UITableViewDataSource, UITableViewDelegate {

and contains the function:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("CELL") as! SingleEventCell

and when I run it - it causes an error that says

fatal error: unexpectedly found nil while unwrapping an Optional value

enter image description here

but when I go to my story, I see:

enter image description here

and when I click CELL, I see in its properties:

enter image description here

as well as:

enter image description here

so the ids for are CELLconfigured, but I still get this error.

What else can I do?

-2
source share
3 answers
  • In the storyboard, select the prototype cell
  • alt+ cmd+ 4To open the Inspector attributes
  • Write CELLin the box Identifier.

Then try again;)

enter image description here

+2
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"CELL"];

.

+1

Try

let cell = tableView.dequeueReusableCellWithIdentifier("CELL", forIndexPath: indexPath) as! SingleEventCell
0
source

Source: https://habr.com/ru/post/1629737/


All Articles