Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New custom cell from XIB causing key value coding-compliant for the key ...?

I've a custom table view cell that I created using XIB:

enter image description here

I've also linked up the XIB file with my custom UITableView cell.

But now when I try to load the cell in - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath with the following codes:

MyCustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (cell == nil) {
        // Load the top-level objects from the custom cell XIB.
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomTableViewCell" owner:cell options:nil];
        // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
        cell = [topLevelObjects objectAtIndex:1];
    }

I'll get a [<NSObject 0x8a5b970> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key hitMeButton.

I have been searching online and one of the possible reasons might be that the XIB is not linked to the IBOutlet, I've checked so that doesn't seem to be the case.

like image 925
tommi Avatar asked Nov 16 '11 02:11

tommi


1 Answers

The real problem is how you've linked the outlets. You have to link your Outlets from the TableViewCell to labels in your cell (you probably linked the label at the File owner's)

Here some more explicative images :

This is ok enter image description here



This is wrong enter image description here

like image 193
MatterGoal Avatar answered Sep 28 '22 10:09

MatterGoal