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

时间:2022-09-02 16:04:02
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while ()
SuppressPerformSelectorLeakWarning(
[_target performSelector:_action withObject:self] //无返回值
);
id result;
SuppressPerformSelectorLeakWarning(
result = [_target performSelector:_action withObject:self] //有返回值
);