Manolo
Manolo

Reputation: 479

Another SIGABRT error

I am getting an error Thread1: signal SIGABRT in the line below, I already tried:

plus look into many posts in this forum.

After all this I deleted all connections with storyboard and connect again but still get the same error :(

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell2 = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as! DefinitionTableViewCell

In the console:

Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-3347.44/UITableView.m:6245

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier cell2 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

Any help is more than welcome Tks :)

Upvotes: 0

Views: 338

Answers (1)

Fengson
Fengson

Reputation: 4912

Well, as the exception message suggests, you "must register a nib or a class for the identifier". Try adding this line in viewDidLoad():

tableView.registerNib(UINib(nibName: "nameOfYourCustomNib", bundle: nil), forCellReuseIdentifier: "cell2")

Replace the nameOfYourCustomNib with your nib name, for example if you have a file MyCustomCell.xib then the name would be MyCustomCell.

If this fails, try registering a class instead of a nib (remember to delete the first line), by typing:

tableView.registerClass(DefinitionTableViewCell.self, forCellReuseIdentifier: "cell2")  

And the most important thing, in cellForRowAtIndexPath, make sure you check if the cell is nil, and if so, create a new DefinitionTableViewCell.

Upvotes: 1

Related Questions