开发者

How to figure out what caused runtime error on IPhone App?

In Xcode, say you write an app for the iphone and it has a runtime error in it. What I've been seeing is that it just closes out the program in the simulator but doesn't really hilight or give me any feedback as to what line caused the crash... am I missing something??

Note: I don't consider the console to be very effec开发者_JS百科tive since it just spits out an error, but I still need to find where in the heck that bug is stemming from in the code.


In the console, above the stack trace, it should say something like "[ClassName selectorName] unrecognized selector sent to instance".

Make sure you really meant to send that selector to that class. If you post what it is, we might be able to help more.

To access GDB, enable breakpoints, add one to your code by clicking in the line number gutter, press build and debug and finally open the debugger (CMD+Shift+Y).


Look in the console (command-shift-R).


You can set a global breakpoint on exceptions, which will let you trace the exact point at which they occurred. To do so, select the Run | Show | Breakpoints menu item in Xcode to bring up the breakpoints dialog. Select Global Breakpoints (so that this will be enabled for all of your projects) and create a breakpoint on objc_exception_throw in libobjc.A.dylib.

Now if you start your application by choosing Run | Debug - Breakpoints On, or manually enable breakpoints in the debugger window (Run | Debugger) before running, the application should halt at the point where the exception is thrown. You can then look at the stack trace in the debugger window, where it will highlight the particular line that caused the exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜