performSelector may cause a leak because its selector is unknown

后端 未结 19 2229
小蘑菇
小蘑菇 2020-11-22 01:54

I\'m getting the following warning by the ARC compiler:

\"performSelector may cause a leak because its selector is unknown\".

Here\'s what

19条回答
  •  忘了有多久
    2020-11-22 02:29

    Here is an updated macro based on the answer given above. This one should allow you to wrap your code even with a return statement.

    #define SUPPRESS_PERFORM_SELECTOR_LEAK_WARNING(code)                        \
        _Pragma("clang diagnostic push")                                        \
        _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"")     \
        code;                                                                   \
        _Pragma("clang diagnostic pop")                                         \
    
    
    SUPPRESS_PERFORM_SELECTOR_LEAK_WARNING(
        return [_target performSelector:_action withObject:self]
    );
    

提交回复
热议问题