2012-03-18 70 views
1

我可以在發佈代碼中使用這個字符串嗎?NSAssert和release

NSAssert([entity buildEntity], @"Building failed at entity with id: %d", entity.entityId); 

[entity buildEntity]返回BOOL並且必須被調用。

所以問題是:如果我關閉斷言中的斷言(Xcode 4的默認行爲),那麼將執行或不執行斷言內的代碼塊?

回答

1

否,buildEntity不會在發佈模式下執行。
使用下面的代碼,這將在調試和發佈模式下表現相同。

id lValue = [entity buildEntity]; 
NSAssert(lValue, @"Building failed at entity with id: %d", entity.entityId);