objective-c "performSelector may cause a leak because its selector is unknown".

OpenSoucre發表於2013-08-29
#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]  //有返回值
);

 

相關文章