How do I find out what exception was thrown in the Xcode debugger (for iPhone)?

前端 未结 4 874
伪装坚强ぢ
伪装坚强ぢ 2020-12-12 14:45

I\'m learning iPhone programming from Erica Sadun\'s The iPhone Developer\'s Cookbook. When I run the app I created by following the steps in the Temperature Conversion Exa

相关标签:
4条回答
  • 2020-12-12 14:56

    Put a breakpoint at objc_exception_throw and run your app via Debug instead of Run

    To clarify, what you're actually seeing when you get an exception without the breakpoint is the same stack trace always - it's the uncaught exception handler. The type of exception is logged to the Run console, but if you want to see a backtrace for where the exception was raised, that's what the breakpoint is for.

    0 讨论(0)
  • 2020-12-12 15:07

    As Kevin answered, you will find more helpful debugging info by setting a breakpoint at objc_exception_throw.

    If you are using Xcode 4.2, you can add this symbolic breakpoint by going to Breakpoint Navigator > Click on the add icon on the bottom left > Add symbolic breakpoint > Enter objc_exception_throw for Symbol > Done.

    0 讨论(0)
  • 2020-12-12 15:08

    http://ijoshsmith.com/2011/11/28/debugging-exceptions-in-xcode-4-2/

    Same as samewize's solution, but also shows how to make this breakpoint show up by default in all your projects (right click on breakpoint, Move Breakpoint To, User).

    0 讨论(0)
  • 2020-12-12 15:12

    In the new Xcode (at least starting from v4.5), you can catch all exceptions easily by doing this:

    1. Bring up breakpoint navigator (⌘6)
    2. Click + on the bottom left
    3. Add Exception Breakpoint

    I think the above is the same as a breakpoint on objc_exception_throw. http://samwize.com/2012/09/26/xcode-4-dot-5-tips-and-tricks/

    0 讨论(0)
提交回复
热议问题