NSUnknownKeyException setValue:forUndefinedKey:

dayitv89 picture dayitv89 · May 31, 2012 · Viewed 31.2k times · Source

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key buttonOfFirstView.'

Why do I get this error? I am trying to make a table cell though XIB. After I add this code it throws the above exception.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier = @"MyCell";

    MyTableViewCell *cell = (MyTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        NSArray *arrayCellXib = [[NSBundle mainBundle] loadNibNamed:@"MyTableViewCell" 
                                                              owner:self 
                                                            options:nil];

....
} 
.....

return cell;
}

How to resolve it?

Answer

iTukker picture iTukker · May 31, 2012

Check your references of your outlets in your XIB, one of them is probably referencing a property (buttonOfFirstView) that does not exist anymore