This quick tip will save you a lot of debugging time!
Sometimes, you have a crash and your call stack looks like:
Well, this callstack doesn’t tell you a lot, apart that your app has crashed somewhere. In the
gdb console, the last message is:
*** Terminating app due to uncaught exception ’NSRangeException’, reason: ’-[__NSCFArray objectAtIndex:]: index (28) beyond bounds (7)
The log is also not very useful, except that you know you have an array overrun. Actually, the default behavior of Xcode is to stop where the exception is caught, not where the exception is raised! This is not very useful but fortunately, Xcode can stop as soon as the exception is raised .
In your project, go to the Breakpoint navigator, click on the ’+’ button and ’Add Exception Breakpoint…’
Click on ’Exception>All’ and ’Break>On Throw’ and ’Done’.
Now, Xcode will break each time a new exception is raised! As you can see in my project, Xcode breaks on the very exact line that has caused an array overrun.
Mmm… Something is bad in this tutorialItems_ array!
The only caveat is that you’ve to do this for each of your project!