9
votes

I'm trying to dismiss a modal view controller and am getting the following error:

* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'

At one point I spent 4 hours trying to debug such error. Can anyone tell me if there's a way to look at stack traces for such errors to understand which object caused the incorrect access?

Thank you!

2

2 Answers

23
votes

if you are running in the debugger, then absolutely you should be able to see the actual line that the exception is being thrown on.

add an exception breakpoint by clicking the breakpoints tab at the top of the left pane, then click the plus sign at the lower left. Add an exception breakpoint.

enter image description here

13
votes

In Xcode 4 you can set an exception breakpoint in the breakpoint editor. Every time an exception is thrown (or caught depending on how you set it up), your application will pause on the line that threw the exception.