我的iOS应用程序出了问题。我用storyboard和一些代码构建了我的应用程序。最初,我有一个TableView,它在第一个标签中显示一些内容。现在我想把这个内容放在另一个标签中,但是当我编辑我的故事板时,我得到了这个错误:
2013-11-28 17:31:17.354 devis_centrage[13961:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
0 CoreFoundation 0x0173a5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bd8b6 objc_exception_throw + 44
2 CoreFoundation 0x016ee9c2 -[__NSArrayI objectAtIndex:] + 210
3 CoreFoundation 0x017b9608 -[NSArray objectAtIndexedSubscript:] + 40
4 devis_centrage 0x000022f8 -[AppDelegate application:didFinishLaunchingWithOptions:] + 936
5 UIKit 0x00225355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
6 UIKit 0x00225b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
7 UIKit 0x0022a3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
8 UIKit 0x0023e87c -[UIApplication handleEvent:withNewEvent:] + 3447
9 UIKit 0x0023ede9 -[UIApplication sendEvent:] + 85
10 UIKit 0x0022c025 _UIApplicationHandleEvent + 736
11 GraphicsServices 0x036e12f6 _PurpleEventCallback + 776
12 GraphicsServices 0x036e0e01 PurpleEventCallback + 46
13 CoreFoundation 0x016b5d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
14 CoreFoundation 0x016b5a9b __CFRunLoopDoSource1 + 523
15 CoreFoundation 0x016e077c __CFRunLoopRun + 2156
16 CoreFoundation 0x016dfac3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x016df8db CFRunLoopRunInMode + 123
18 UIKit 0x00229add -[UIApplication _run] + 840
19 UIKit 0x0022bd3b UIApplicationMain + 1225
20 devis_centrage 0x00002ccd main + 141
21 libdyld.dylib 0x01d7870d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
这里是数组初始化的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_aircraft = [NSMutableArray arrayWithCapacity:20];
Aircraft *aircraft = [[Aircraft alloc] init];
aircraft.name = @"Robin DR400";
aircraft.immat = @"F-HAZA";
[_aircraft addObject:aircraft];
aircraft = [[Aircraft alloc] init];
aircraft.name = @"Tecnam P2002 JF";
aircraft.immat= @"F-HAZB";
[_aircraft addObject:aircraft];
aircraft = [[Aircraft alloc] init];
aircraft.name = @"Tecnam P2002 JF";
aircraft.immat= @"F-HAZC";
[_aircraft addObject:aircraft];
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = [tabBarController viewControllers][0];
AircraftViewController *aircraftViewController = [navigationController viewControllers][0];
aircraftViewController.aircraft = _aircraft;
return YES;
}
答案 0 :(得分:0)
您正在访问数组中的第二个对象。如果您尝试访问它,那么它(对象)就在您的数组中。也许你忘记了它。