performSelector may cause a leak because its selector is unknown

后端 未结 19 2246
小蘑菇
小蘑菇 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:47

    To make Scott Thompson's macro more generic:

    // String expander
    #define MY_STRX(X) #X
    #define MY_STR(X) MY_STRX(X)
    
    #define MYSilenceWarning(FLAG, MACRO) \
    _Pragma("clang diagnostic push") \
    _Pragma(MY_STR(clang diagnostic ignored MY_STR(FLAG))) \
    MACRO \
    _Pragma("clang diagnostic pop")
    

    Then use it like this:

    MYSilenceWarning(-Warc-performSelector-leaks,
    [_target performSelector:_action withObject:self];
                    )
    

提交回复
热议问题