您好我之前正在做一些測試,我的應用程序運行得很好。我想做一些更多的測試,所以我決定從我的設備中刪除應用程序,然後通過運行重新安裝。應用程序在啓動時崩潰
現在好了,由於某種原因,我得到的地方,我的啓動畫面顯示搭臺,然後它崩潰,我得到的錯誤:
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調試發生這種情況?謝謝 –