为什么NSAssert在main中而不是在调用断言的代码中中断 [英] Why does NSAssert break in main instead of in the code that call the assertion
问题描述
我设置了此NSAssert
I set this NSAssert
NSAssert(isStillLoadingArgument== [[self class] stillLoading],@"Hmm.... we think isStill Loading is false or true and yet stillLoading is true");;
这是我问这个问题的屏幕截图:
Here is the screenshot of where I ask this question:
然后,当断言失败时,代码将在此处中断:
Then when assertion fail, the code break here:
这很烦人,因为我想看看我设置断言的代码断言.所以,我该怎么做.
Which is very annoying because I want to see the assertion break on the code I set up the assertion instead. So, how do I do so.
不幸的是,本答案没有解决问题:
Ben answer unfortunately doesn't solve the issue:
推荐答案
您需要为所有异常将断点添加到项目中.
You need to add a Breakpoint to your project for all exceptions.
1)单击断点导航器
2)添加异常断点
3)确保将其设置为在所有例外情况下都可以终止
3) Make sure you set it to break on all exceptions
现在,XCode将打破实际的断言,而不是main.希望这会有所帮助!
Now XCode will break to the actual assert rather than main. Hope this helps!
这篇关于为什么NSAssert在main中而不是在调用断言的代码中中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!