#nsassert
Explore tagged Tumblr posts
Text
NSAssert References self
NSAssert and its related macros reference self. If you NSAssert in a block that self retains, you will create a retain cycle. This only occurs when running in any build configuration that doesn't block assertions.
#define NSAssert(condition, desc, ...) \ do { \ __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \ if (!(condition)) { \ [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \ object:self file:[NSString stringWithUTF8String:__FILE__] \ lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \ } \ __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \ } while(0)
You can use NSCAssert to get around this, but that technically isn't supposed to be used in Objective-C methods.
I discovered this bug while reading Drew Crawford's post on NSNotificationCenter.
4 notes
·
View notes