2016-02-09 11:25:11.773 TableView[1408:94586] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray' *** First throw call stack: ( 0 CoreFoundation 0x0000000111c5fe65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001116d6deb objc_exception_throw + 48 2 CoreFoundation 0x0000000111c0e395 -[__NSArray0 objectAtIndex:] + 101 3 TableView 0x000000010f949046 -[FlightDetailsViewController loadInfoToEdit] + 310 4 TableView 0x000000010f94887d -[FlightDetailsViewController viewDidLoad] + 509 5 UIKit 0x0000000110348f98 -[UIViewController loadViewIfRequired] + 1198 6 UIKit 0x000000011034ef4f -[UIViewController __viewWillAppear:] + 120 7 UIKit 0x000000011037ee44 -[UINavigationController _startCustomTransition:] + 1203 8 UIKit 0x000000011038f23f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712 9 UIKit 0x00000001103903af -[UINavigationController __viewWillLayoutSubviews] + 57 10 UIKit 0x0000000110536ff7 -[UILayoutContainerView layoutSubviews] + 248 11 UIKit 0x00000001102694a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703 12 QuartzCore 0x000000011507759a -[CALayer layoutSublayers] + 146 13 QuartzCore 0x000000011506be70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 14 QuartzCore 0x000000011506bcee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 15 QuartzCore 0x0000000115060475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277 16 QuartzCore 0x000000011508dc0a _ZN2CA11Transaction6commitEv + 486 17 UIKit 0x00000001101ddb47 _afterCACommitHandler + 174 18 CoreFoundation 0x0000000111b8b367 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 19 CoreFoundation 0x0000000111b8b2d7 __CFRunLoopDoObservers + 391 20 CoreFoundation 0x0000000111b80f2b __CFRunLoopRun + 1147 21 CoreFoundation 0x0000000111b80828 CFRunLoopRunSpecific + 488 22 GraphicsServices 0x0000000114b2aad2 GSEventRunModal + 161 23 UIKit 0x00000001101b2610 UIApplicationMain + 171 24 TableView 0x000000010f94855f main + 111 25 libdyld.dylib 0x00000001126f292d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
0
votes
1 Answers
1
votes
As others have mentioned (and your output clearly states) your NSArray is empty. If you attempt to reference an index from an NSArray that does not exist it will crash every time.
Apparently you are attempting to access an object at index 0. You can error check that the array has at least the number of items as the index number as such:
NSArray *myArray = [NSArray arrayWithObject:@"foo"];
int indexDesired = 0; //since you were attempting to access index 0
long indexCount = [myArray count];
if (indexCount > indexDesired) { //check to make sure index exists
id myObject = [myArray objectAtIndex:indexDesired];
}