码迷,mamicode.com
首页 > 移动开发 > 详细

iOS疯狂详解之warning:performSelector may cause a leak because its selector is unknown

时间:2014-12-15 15:31:53      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:ios开发   performselector   警告   爆黄   

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

#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

标签:ios开发   performselector   警告   爆黄   

原文地址:http://blog.csdn.net/wanglongblog/article/details/41943303

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!