[置顶] Objective-c中在ARC环境下使用PerformSelector方法回产生警告

Objective-c中在ARC环境下使用PerformSelector方法回产生警告:PerformSelector may cause a leak because its selector is unknown 

解决办法是:添加这三行代码

#pragma clang diagnostic push

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

#pragma clang diagnostic pop

举例子:

#pragma clang diagnostic push

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

    if ([self.target respondsToSelector:self.action]) {

        [self.target performSelector:self.action withObject:self];

    }

#pragma clang diagnostic pop



你可能感兴趣的:(ios,Objective-C,Clang)