当前位置:首页 > 开发 > 移动开发 > 正文

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

发表于: 2014-04-06   作者:G10A   来源:转载   浏览:
ios
摘要: 在ARC下使用  1 [theTarget performSelector:theTarget withObject:Nil]; 会出现警告:performselector-may-cause-a-leak-because-its-selector-is-unknown  解决方法: 1:添加如下宏 1 #define S

在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

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

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号