Ch. 7 View Controller compile error


After completing page 132, I get this error when I build and run the application and hit the “Right” tab button (CurrentTimeViewController):

“Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: '[<CurrentTimeViewController 0x4b4d630> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key delegate.” … then error more stuff…

This is my second time writing the project. The first time it worked, up to page 136. Then when I tried the implementation of the XIB, it didn’t work when I hit the “Time” tab button

Also I got this thingy…
Thread 1: program receive signal: SIGBART
Here’s my code:

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    // Override point for customization after application launch.

    // create a tabBar controller
    UITabBarController * tabBarController = [[UITabBarController alloc]init];

    // create two view controllers
    UIViewController * vc1 = [[HypnosisViewController alloc] init];
    UIViewController * vc2 = [[CurrentTimeViewController alloc] init];

    // make an array containing the two view controllers
    NSArray * viewControllers = [NSArray arrayWithObjects:vc1, vc2, nil];

    // the view controllers array objects we can release our ownership of them
    [vc1 release];
    [vc2 release];

    // attach the array objects to the tab bar
    [tabBarController setViewControllers:viewControllers];

    // set the tab bar controller as the rottViewController of the window
    [[self window] setRootViewController:tabBarController];

    // the window retains tabBarController, we can release it
    [tabBarController release];

    [self.window makeKeyAndVisible];
    return YES;

Thanks in advance -Lawrence


I may have fixed it. it works sofar. I isolated it to the CurrentTimeViewController.h. I made a new file with a different name. it worked.

If I use that name “CurrentTimeViewController” I get a error/crash when I hit the tab button. I even declared 4 tab with different names and they work. but when I use that name, no que passa. Weird! any ideas???


I get the same thing. I am on a Mac running Lion and I installed Xcode 4.1 (per the instructions on this forum). If I name it something else this error goes away.


This is a problem with your XIB file, you have somehow connected CurrentTimeViewController’s “delegate” outlet to another object - the problem is, CurrentTimeViewController doesn’t have a delegate outlet.

Go into the XIB, right-click on File’s Owner, disconnect delegate - it should have a yellow warning sign next ot it.


On Xcode 4.2 I get the following error with CurrentTimeViewController:

2011-12-23 11:23:03.625 HypnoTime[84298:f803] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CurrentTimeViewController 0x685e6f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key timeLabel.'

Like the above posters, I did not get this error if I named the class differently.

EDIT: Also this was just with the empty View Controller classes.