Why does assert simply terminate a program compiled for iPhone?

前端 未结 4 1875
-上瘾入骨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条回答
  •  Happy的楠姐
    2020-12-24 10:05

    In Xcode 4 and new iOS, NSAssert may actually take a variable list of parameters. This may be useful to log some values together with the assert. The compiling-out assert (see answer by Mike above) could be defined like this:

    #ifdef DEBUG
    #   define DAssert(A, B, ...) NSAssert(A, B, ##__VA_ARGS__);
    #else
    #   define DAssert(...);
    #endif
    

    Also, there is no longer Run → Show → Breakpoints menu item. See this post to set up Xcode 4 to break on an assert as defined above.

提交回复
热议问题