Why does assert simply terminate a program compiled for iPhone?

前端 未结 4 1877
-上瘾入骨i
-上瘾入骨i 2020-12-24 09:54

I\'m debugging a heavily assert()\'ed iPhone app (Xcode, Objective-C++, and device simulator). In some cases, the assert failure would just terminate the app, instead of bre

4条回答
  •  暖寄归人
    2020-12-24 10:22

    First of all, if you "Add Exception Breakpoint..." in the Breakpoint Navigator (⌘6), the debugger will stop on NSAssert's failures, allowing you to look at the stack and understand what went wrong.

    You should use the standard NSAssert. If you use it correctly, there is not a lot that you need to manually create -- everything Mike mention is similar to the default NSAssert implementation.

    You should run you release configuration with NS_BLOCK_ASSERTIONS set in your precompiled headers (follow Mike's steps), to disable assertions. If you need more info on why to do so, check out: http://myok12.wordpress.com/2010/10/10/to-use-or-not-to-use-assertions/

提交回复
热议问题