在ARC下使用
1 | [theTarget performSelector:theTarget withObject:Nil]; |
会出现警告:performselector-may-cause-a-leak-because-its-selector-is-unknown
解决方法:
1:添加如下宏
1 | #define SuppressPerformSelectorLeakWarning(Stuff) \ |
2 | do { \ |
3 | _Pragma( "clang diagnostic push" ) \ |
4 | _Pragma( "clang diagnostic ignored \"-Warc-performSelector-leaks\"" ) \ |
5 | Stuff; \ |
6 | _Pragma( "clang diagnostic pop" ) \ |
7 | } while (0) |
2:使用宏
1 | SuppressPerformSelectorLeakWarning([theTarget performSelector:theAction withObject:@ "hello" ]); |