2013-08-20 107 views
3

NS_BLOCK_ASSERTIONS是否關閉了呼叫:NSAssert調用或者還有assert()調用。我的應用在assert(...)聲明中的發行模式下崩潰。NS_BLOCK_ASSERTIONS是否禁用NSAssert和assert()調用?

documentation說,只有約NSAssert enter code here如果斷言()enter code here呼叫被禁用並沒有告訴。

有幾個與我的相關問題沒有回答。我在這裏聯繫起來:

NS_BLOCK_ASSERTIONS in Objective-C
NSAssert vs. assert: Which do you use, and when?
How to know if NSAssert is disabled in release builds?

+0

我們不需要在Swift中使用NS_BLOCK_ASSRETIONS,因爲所有的斷言只有在Debug模式下才有效。 –

回答

6

沒有,assert()控制與NDEBUG符號:

#ifdef NDEBUG 
#define assert(e) ((void)0) 
#else 
... 

(見/usr/include/assert.h,如果您有Xcode的命令行工具安裝,或Xcode.app包中的其他地方,如果沒有的話)。