8

I have an NSRangeException error that does not occur all the time(especially when I am debugging). It comes up randomly, and I am unable to figure out where it is coming from. I have lots of array manipulation, so its difficult to eliminate it that way.

My question is whether I can get a clue , for example class and line number from the debugger output, for example what are the numbers 12109 and 707?:

2012-03-15 09:25:15.303 appname[12109:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 0]'

Any pointers appreciated.

Edit: Remaining part of the log:

*** First throw call stack:
(0x33ff38bf 0x342431e5 0x33f4b275 0x1702d 0x37662331 0x3761b2b3 0x33f4d435 0x373b79eb 0x373b79a7 0x373b7985 0x373b76f5 0x3744de55 0x374e3e45 0x373aa99b 0x33fc7b4b 0x33fc5d87 0x33fc60e1 0x33f494dd 0x33f493a5 0x307cdfcd 0x373ca743 0x2325 0x22e4)
terminate called throwing an exception
user542584
  • 2,651
  • 2
  • 25
  • 29

2 Answers2

53

Add an Exception breakpoint. This will stop on the line that raises the exception.

In the breakpoints navigator, click the plus in the bottom left, choose exception breakpoint, and all exceptions. You should have this on all projects really, it is invaluable. We'd have far fewer questions here, though!

jrturton
  • 118,105
  • 32
  • 252
  • 268
1

Look further down in your crash log, and chances are that at some point it will point to an actual method and line.

For e.g. in the below block from a device crash log, the last line clearly points to the request:didLoad: method in the FacebookController.m class at line 264.

0x33defacb -[NSObject doesNotRecognizeSelector:] + 175
0x33dee945 ___forwarding___ + 301
0x33d49680 _CF_forwarding_prep_0 + 48
0x00037e47 -[FacebookController request:didLoad:] (FacebookController.m:264)
Madhu
  • 2,429
  • 16
  • 31
  • Hi, Thanks for the answer, unfortunately, it does not show any of that. I have edited the question with the remaining part of the crash log – user542584 Mar 15 '12 at 10:46