您的位置:首页 > 其它

warning:performSelector may cause a leak because its selector is unknown

2015-10-28 10:33 344 查看
在使用 performSelector: withObject: 函数出现“performSelector may cause a leak because its
selector is unknown”。

主要是警告信息,在非ARC项目中没有这个警告。如果是在某一处修改只需要加入下列代码

#pragma clang diagnostic push

#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

[vcappear performSelector:selector
withObject:nil];

#pragma clang diagnostic pop


如果在程序中多次使用可以设置一下宏

#define SuppressPerformSelectorLeakWarning(Stuff) \

do { \

_Pragma("clang diagnostic push") \

_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \

Stuff; \

_Pragma("clang diagnostic pop") \

} while (0)


如果没有返回值

SuppressPerformSelectorLeakWarning(

[_target performSelector:_action withObject:self]

);


有返回值

id result;

SuppressPerformSelectorLeakWarning(

result = [_target performSelector:_action withObject:self]

);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: