How to fix RELEASE_SAFELY macro warning?
in my class I define the following macro
#define RELEASE_SAFELY(__POINTER){[__POINTER release]; __POINTER = nil;}
But I get this 开发者_如何学Cwarning on that:
How can I fix that?
ABMultiValueRef is a Core Foundation object which should be freed using CFRelease, not -release
.
#define RELEASE_SAFELY_CF(X) { CFRelease(X); X = NULL; }
If you don't want to create 2 macros, you could use a cast [(id)__POINTER release]
. But I don't recommend this, as there is no rule saying all CFType can be sent Objective-C methods.
define RELEASE_SAFELY(__POINTER){[ (id) __POINTER release]; __POINTER = nil;}
add the "(id)" cast like the warning says.
精彩评论