Determining where in the code an error came from - iPhone
- by Robert Eisinger
I'm used to Java programming where an error is thrown and it tells you at what line the error was thrown from which file. But with Objective-C in XCode, I can't ever tell where the error comes from. How can I figure out where the error came from? Here is an example of a crash error:
2011-01-04 10:36:31.645 TestGA[69958:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x01121be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012765c2 objc_exception_throw + 47
2 CoreFoundation 0x011176e5 -[__NSArrayM objectAtIndex:] + 261
3 TestGA 0x000548d8 -[S7GraphView drawRect:] + 5763
4 UIKit 0x003e16eb -[UIView(CALayerDelegate) drawLayer:inContext:] + 426
5 QuartzCore 0x00ec89e9 -[CALayer drawInContext:] + 143
6 QuartzCore 0x00ec85ef _ZL16backing_callbackP9CGContextPv + 85
7 QuartzCore 0x00ec7dea CABackingStoreUpdate + 2246
8 QuartzCore 0x00ec7134 -[CALayer _display] + 1085
9 QuartzCore 0x00ec6be4 CALayerDisplayIfNeeded + 231
10 QuartzCore 0x00eb938b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 325
11 QuartzCore 0x00eb90d0 _ZN2CA11Transaction6commitEv + 292
12 QuartzCore 0x00ee97d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
13 CoreFoundation 0x01102fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
14 CoreFoundation 0x010980e7 __CFRunLoopDoObservers + 295
15 CoreFoundation 0x01060bd7 __CFRunLoopRun + 1575
16 CoreFoundation 0x01060240 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x01060161 CFRunLoopRunInMode + 97
18 GraphicsServices 0x01932268 GSEventRunModal + 217
19 GraphicsServices 0x0193232d GSEventRun + 115
20 UIKit 0x003b842e UIApplicationMain + 1160
21 TestGA 0x00001cd8 main + 102
22 TestGA 0x00001c69 start + 53
23 ??? 0x00000001 0x0 + 1
So from looking at this, where is the error coming from and from which class is it coming from?