내 iOS 앱에 문제가 있습니다. 스토리 보드 및 일부 코드로 앱을 제작했습니다. 처음에는 첫 번째 탭에 일부 내용을 표시하는 TableView가있었습니다. 지금은 다른 탭에서이 내용을 넣어 싶습니다,하지만 난 내 스토리 보드를 편집 할 때이 오류가 얻을 :캐치되지 않은 예외 'NSRangeException'으로 인한 앱 종료 중, 이유 : '*** - [__ NSArrayI objectAtIndex :] : 경계 1 [0 .. 0]을 넘는 인덱스 1'
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;
}
'application : didFinishLaunchingWithOptions :'에서 액세스하려고 시도하는 배열 중 하나가 비어 있습니다. –
배열을 할당하고 초기화 했습니까? 배열을 생성하는 코드와 항목을 추가하는 위치를 게시 할 수 있습니까? – Greg
크래시 리포트의 상징으로, 잘못된 배열 접근으로 문제를 일으키는'application : didFinishLaunchingWithOptions :'메소드의 정확한 라인을 보여줍니다. – rmaddy