Viewcontroller not loading
Working on a tabbed ipad application. My program builds but fails to
launch with the error given below on this line from the AppDelegate.m,
self.tabBarController.viewControllers = @[viewController1, viewController2];
This code has not been edited ie straight from the template and has worked
correctly until now. The view controllers seem to initiate, and show valid
properties in the inspector when debugging. I am assuming the NSrange
error is referring to the self.tabBarController.viewControllers array,
maybe that's not true.
It's hard to imagine how I caused this error to occur. Any suggestions
gratefully accepted, particularly obtaining more info to isolate the
error.
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc]
initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc]
initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1,
viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
* Terminating app due to uncaught exception 'NSRangeException', reason: '*
-[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
No comments:
Post a Comment