首页 > 代码库 > iOS疯狂详解之warning:performSelector may cause a leak because its selector is unknown
iOS疯狂详解之warning:performSelector may cause a leak because its selector is unknown
主要是警告信息,在非ARC项目中没有这个警告。如果是在某一处修改只需要加入下列代码:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];//此处是你调用函数的地方
#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]
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];//此处是你调用函数的地方
#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]
);
更多iOS疯狂详解:http://blog.csdn.net/wanglongblog
iOS疯狂详解之warning:performSelector may cause a leak because its selector is unknown
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。