您好我之前正在做一些测试,我的应用程序运行得很好。我想做一些更多的测试,所以我决定从我的设备中删除应用程序,然后通过运行重新安装。应用程序在启动时崩溃
现在好了,由于某种原因,我得到的地方,我的启动画面显示搭台,然后它崩溃,我得到的错误:
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]'
这显然意味着那里有一个数组越界正确的?但是为什么现在和怎样才能找出这种情况发生在哪里以及哪些视图控制器上?它怎么能运行之前,现在突然间,当我尝试通过再次运行重新安装应用程序我得到这个错误?
感谢
编辑 错误与下面的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
exploreViewController *view1 = [[exploreViewController alloc] initWithNibName:@"exploreViewController" bundle:nil];
view1.title= @"Explore";
Upcoming *view2 = [[Upcoming alloc] initWithNibName:@"Upcoming" bundle:nil];
view2.title = @"Upcoming";
calcViewController *view3 = [[calcViewController alloc] initWithNibName:@"calcViewController" bundle:nil];
view3.title = @"Calc";
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:view1];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:view2];
UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:view3];
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nil];
self.tabBarItem = [[[UITabBarItem alloc] init] autorelease];
NSArray *tabBarItems = self.tabBarController.tabBar.items;
UIImage *tab1 = [UIImage imageNamed:@"85-trophy.png"];
UIImage *tab2 = [UIImage imageNamed:@"12-eye.png"];
UIImage *tab3 = [UIImage imageNamed:@"237-key.png"];
NSArray *tabBarImages = [[[NSArray alloc] initWithObjects:tab1, tab2, tab3,nil]autorelease];
NSInteger tabBarItemCounter;
for (tabBarItemCounter = 0; tabBarItemCounter < [tabBarItems count]; tabBarItemCounter++)
{
tabBarItem = [tabBarItems objectAtIndex:tabBarItemCounter];
tabBarItem.image = [tabBarImages objectAtIndex:tabBarItemCounter];
}
请张贴代码 –
显示为NSArray的和相关的循环的代码。 – Sarah
@ColeJohnson以大量代码发布......大型应用程序。有没有通过Xcode调试发生这种情况?谢谢 –