Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Deep dive Notification project throwing Exception

I'm at the end of the third and last video on the iOS Notification deep dive and i'm getting an exception even though I am following the videos/project code exactly.

The exception is coming from the code added to my AppDelegate.m in the line:

self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];

And my whole didFinishLaunchingWithOptions: method is as followed:

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    UIViewController *viewController1 = [[UIViewController alloc]initWithNibName:@"FirstViewController" bundle:nil]; UIViewController *viewController2 = [[UIViewController alloc]initWithNibName:@"SecondViewController" bundle:nil]; self.tabBarController = [[UITabBarController alloc]init]; self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];

    [[NSNotificationCenter defaultCenter] addObserver:viewController2 selector:@selector(textFieldChanged:) name:@"textFieldChanged" object:nil];

    self.window.rootViewController = self.tabBarController; [self.window makeKeyAndVisible]; return YES; }

Lastly, my Exception error is below: AssertMacros: queueEntry, file: /SourceCache/IOKitUser/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512 2013-09-30 14:39:34.948 Notification2[3543:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/F844F8D5-7B2B-4688-9D29-24BCDED38304/Notification2.app> (loaded)' with name 'FirstViewController'' *** First throw call stack: (0x2d9fded3 0x37a266c7 0x2d9fde15 0x30243799 0x301a5dab 0x300089f9 0x2fee9995 0x2fee9911 0x30011b8f 0x30011a23 0x3001192f 0x2fef6efd 0x3000cced 0x4a3a3 0x2ff56acd 0x2ff56513 0x2ff50b79 0x2feeabfb 0x2fee9ef1 0x2ff50359 0x323c67c5 0x323c63af 0x2d9c877f 0x2d9c871b 0x2d9c6ee7 0x2d931541 0x2d931323 0x2ff4f5fb 0x2ff4a8a5 0x4aef5 0x37f3bab7) libc++abi.dylib: terminating with uncaught exception of type NSException

Can you explain why this is causing this error? The code is exact and the only thing different is i'm using a Storyboard, because iOS7 automatically generates one when you chose a tabbed application, and won't allow you to uncheck "Use Storyboards" like iOS5 and 6 would.

Thanks,

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

You are right, the error is related to the fact you are using the storyboard. You might want to create the tab bar controller using the storyboard. Here's a tutorial on how to do it: http://teamtreehouse.com/library/ios-development/build-a-selfdestructing-message-app/designing-and-starting-the-app/a-storyboard-with-a-tab-bar-controller