How to make Xcode4 stop at NSAssert failure?

2019-03-08 10:19发布

Currently, my Xcode4 does not stop at NSAssert failure. How can I make it stop at NSAssert failure again?

标签: xcode4
3条回答
老娘就宠你
2楼-- · 2019-03-08 10:58
  1. Go to the XCode 4 breakpoint navigator.
  2. Click the + button and choose "Add Symbolic Breakpoint"
  3. Set Symbol: to "-[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]"
  4. Click "Done"

Now you will stop in the debugger as soon as NSAssert fires. In my testing, it goes to the nearest source code and doesn't just show you the assembly where you set the breakpoint.

More Generically, you could do this:

  1. Go to the breakpoint navigator.
  2. Click the + button and choose "Add Exception Breakpoint"
  3. Set Exception: to "Objective-C"
  4. Set Break: to "On Throw"
  5. Click "Done"

This may be more or less useful depending on your code.

See also the XCode 4 documentation result for "Adding an Exception Breakpoint"

查看更多
戒情不戒烟
3楼-- · 2019-03-08 11:18

i'm boring for the problem. i think blow blog may be useful. http://www.learn-cocos2d.com/tag/nsassert/ http://edmundlong.com/edsBlog/making-nsassert-work/

查看更多
再贱就再见
4楼-- · 2019-03-08 11:22

Assertions are automatically disabled, by default, in a Release build. If you want assertions to work, do a Debug build, or turn off the Other C Flags build setting where assertions are turned off in the Release build.

查看更多
登录 后发表回答