3

In Navigation-based App, when i try to load another view which has got implemented UITableView using initWithNibName:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UIViewController *detailsViewController = [[UIViewController alloc] initWithNibName:@"bloop2ViewController" bundle:nil];
    [[self navigationController] pushViewController:detailsViewController animated:YES];
    [detailsViewController release];
}

after clicking UITableView cell i get:

2009-06-13 11:44:41.089 Bloop[75227:20b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0xd446f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key tableView.' 2009-06-13 11:44:41.092 Bloop[75227:20b] Stack: (
807902715, 2429103675, 808061681, 810717848, 810716389, 816538544, 807805711, 816533170, 816541363, 815230552, 815224116, 815223834, 815217291, 815258907, 815254969, 815262662, 815243017, 815265053, 815242666, 11044, 815018240, 815005661, 810768858, 807687328, 807683624, 839142449, 839142646, 814752238, 9088, 8942 )

But when i disconnect UITableView in InterfaceBuilder, view is loaded without any problems (except there's no way to push data into it).

UITableView implementation is proper - i tried it in a fresh XCode project, and it worked just fine.

5 Answers5

6

The error message says you are trying to set the property "tableView" on an object of type UIViewController, which it does not have. I am just guessing, but maybe you have a derived view controller in your nib file, that has the property tableView, but then you construct not your derived object, but a UIViewController. You should try:

MyTableViewController *detailsViewController = [[MyTableViewController alloc] initWithNibName:@"bloop2ViewController" bundle:nil];
nschmidt
  • 2,383
  • 16
  • 22
0

Yet another way this can bite you. I had tossed out the xib for a view and started over. No matter what I did, the view threw this exception on load. After pulling my hair out for several hours, I finally deleted the app from the simulator and that fixed it. Somehow the old xib wasn't being replaced on install.

David Gish
  • 750
  • 6
  • 14
0

After 2 hours on this i forgot to

@synthesize tableView = _tableView;

Hope it helps

Mário

Mário Carvalho
  • 3,106
  • 4
  • 22
  • 26
0

I was getting this problem and the fix was to make sure both

  1. I set the NIB name in the view controller beneath the tab bar in the main window xib, and
  2. the class name was set in the sub-viewcontroller.

This page was helpful for me.

nornagon
  • 15,393
  • 18
  • 71
  • 85
0

I just experienced this issue. In my case the cause was the implementation code for MyTableViewController was being excluded from the current build configuration. Hope that helps someone.

Chris Lacy
  • 4,222
  • 3
  • 35
  • 33