11

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?

CRABOLO
  • 8,605
  • 39
  • 41
  • 68
gauravds
  • 2,931
  • 2
  • 28
  • 45

5 Answers5

49

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

iTukker
  • 2,083
  • 2
  • 16
  • 16
2

Set File's Owner class to NSObject and set UITableViewCell class to your custom class in XIB. It will solve the issue.

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Augustine P A
  • 5,008
  • 3
  • 35
  • 39
1

This is exactly an issue related to the key buttonOfFirstView in your case.If it is a button it may be connected wrongly in any of your xibs

iOS Developer
  • 1,723
  • 2
  • 16
  • 47
0

Quit the iOS simulator. Make sure you save the project and then quit xCode and restart and everything will be fine. I did that and it worked for me. that's if everything else is hooked up correctly.

0

you need to clean your project: go to Product -> Clean

this works for me

Matias Elorriaga
  • 8,880
  • 5
  • 40
  • 58