简体   繁体   中英

iOS crash before didFinishLaunchingWithOptions: index 0 beyond bounds for empty array

update

I solved this problem by myself. I put it here for further reference. I found that I wired rootViewController of window to tabBarController in MainWindow.xib , instead of add the following line in didFinishLaunchingWithOptions :

[self.window setRootViewController:self.tabBarController];

Everything is fine after removing the link in MainWindow.

I guess it may triggered the view of the first tab, which has an un-initialed array.

Anyway, I still dont no why it is ok under ios4.

Thanks.

在此处输入图片说明


update

thanks for comments and answers, it happens before getting into didFinishLaunchingWithOptions. however I still paste didFinishLaunchingWithOptions here to see if I miss anything.

ps: it works perfect on ios 4.x

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    return YES;
}

Hi I got a strange problem which happens before didFinishLaunchingWithOptions, so I have no idea how to handle it. Can anyone give any hint? Thanks you.

2012-03-10 18:03:12.642[95579:17003] Unresolved error (null), (null)
2012-03-10 18:03:12.644[95579:17003] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1a07052 0x1fbbd0a 0x19f3db8 0x16c57 0x19d15 0x973e 0x8665 0xa1a64e 0xa19c1c 0xa4056d 0xa2ad47 0xa41441 0xa4145d 0xa4145d 0xa414f9 0x981d65 0x981dac 0xb7274e 0xb74010 0x95414a 0x954461 0x9537c0 0x962743 0x9631f8 0x956aa9 0x28f4fa9 0x19db1c5 0x1940022 0x193e90a 0x193ddb4 0x193dccb 0x9532a7 0x954a9b 0x2690 0x1eb5)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c

Check first if the array is empty:

if ([array count] > 0) {
/* do something with your array */
}

If you need to look inside the array, set a breakpoint and look inside while debugging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM