解决ARC下performselector-may-cause-a-leak-because-its-selector-is-unknown警告

在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"]);

  

参考:http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown

你可能感兴趣的:(ios)