0

I was curious why I would be getting a SIGABRT error when I am customizing a tableview cell on a controller. The Cell is created in a UITableViewCell class everything is linked that I can see. The UITableViewController is not the rootController but a controller off the root off another UITableViewController. so RootView -> TableViewCont -> This TableViewCont.

The error is in the cellForRowAtIndexPath function:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
  (NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"CellTest";

CellTest *cell = (CellTest *)
                [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    NSArray *topLevelObjects = [[NSBundle mainBundle]
                                loadNibNamed:@"CellTest" owner:self 
                                options:nil];//**error is thrown here**//
    for(id currentObject in topLevelObjects){
        if([currentObject isKindOfClass:[UITableViewCell class]]){
            cell = (CellTest *) currentObject;
            break;
        }
    }
}

// Configure the cell...
cell.cellTitle.text = @"Test";
cell.cellDescription.text = @"little detail";

return cell;
}

This is the error in the gdb log:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<DemoViews 0x6b16ce0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cellDescription.
5
  • Are you sure you have everything included? Try cleaning the project. I have the same code in my app and it's working like a charm... Commented Mar 2, 2012 at 20:46
  • It says that everything is clean. Would it make a difference that the file that has the table is just a UITableViewController that is not the root and that the Cell code is just a UITableViewCell. Do I have to add anything to the .xib for the UITableViewController Commented Mar 2, 2012 at 20:55
  • It must be something strange in the xib. Is the "Custom Class" for the UITableViewCell set properly? It's UITableViewCell by default, but you probably need it to be CellTest. Commented Mar 2, 2012 at 21:13
  • The class is set to CellTest in the CellTest.xib Commented Mar 2, 2012 at 21:19
  • The file owner of the file CellTest.xib is CellTest? It should... Commented Mar 3, 2012 at 2:09

1 Answer 1

2

I had the same issue and did not understand why I am getting SIGABRT. However I resolved the problem:

  1. First place the layout of your cell into a separate xib. Don't ask why, it just doesn't work if there're other things in the xib.
  2. Now you can follow the recipe of Apple for creating custom cells.
Sign up to request clarification or add additional context in comments.

4 Comments

This worked. The one thing I would like to add to the separate xib, which is mentioned on the site is that it is an empty User Interface only xib. Also, one thing that I do not feel apple made clear, which is partially my fault with my understanding, is that the static NSString is the id you give to the cell and the loadNibName is the name of the xib file.They do say it in the text, but I find it a little confusing because they do not mention the nibName when you add it to the .m file just when you create the file. So those are a few things I noticed that will make it easier for others.
eh, yes, I also spent 1 day+ with this some time ago, and you really have to pay attention on every word in the article to make it working. Glad you succeed.
@MrTJ Wow im glad I found this link. Little question: What if you have 3 different customized cells in the same tableview - how could this be done? (so I cal choose which cell to be used fx: TVCell1, TVCell2 & TVCell3)
If you need all three cells at the same time I guess it should work that you create three instance variables connected to the xib. If you need them at different time, you can release those one you don't need at the moment, or separate them into three different file owners. However if you have to create such a complex table and you don't have particular reason to work with xibs, I strongly suggest you to check out the segues: it is much easier to create custom tables with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.