Exception

Debbuging trick for Xcode

Wednesday, November 19th, 2008 | Programming | 3 Comments

If you make an error which throws an exception, its sometimes quite hard to trance the error. Usually you have to set a breakpoint and step thru the code to find the line which throws the exception.

Woudn’t it be better, if the debugger stops automatically at the line of code, which throws the exception? I say yes, such things can make life easier and it is possible, since Xcode provides a feature called symbolic breakpoints.
To achieve this behaviour go to Build/Manage breakpoints/Add symbolic breakpoint and enter objc_exception_throw
Now create a programmatical error in your code (e.g. try to get an object in a NSArray with a non existing index) and start the debugger (Apple + Y). The debugger will stop exactly on the line of code, where the exception has been thrown.

Tags: , , ,