开发者

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 to fix RELEASE_SAFELY macro warning?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜