warning:performSelector may cause a leak because its selector

   

在ARC项目中使用 performSelector: withObject: 函 数出现“performSelector may cause a leak because its selector is unknown”。在stackoverflow找到了一个解决方案,地址:http://stackoverflow.com/questions /7017281/performselector-may-cause-a-leak-because-its-selector-is- unknown。

主要是警告信息,在非ARC项目中没有这个警告。如果是在某一处修改只需要加入下列代码:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];//此处是你调用函数的地方
#pragma clang diagnostic pop
如果在程序中多处使用,可以写一个宏定义,如下:
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored "-Warc-performSelector-leaks"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)
如果没有返回结果,可以直接按如下方式调用:
SuppressPerformSelectorLeakWarning(
[_target performSelector:_action withObject:self]
);
如果要返回结果,可以按如下方式调用:
id result;
SuppressPerformSelectorLeakWarning(
result = [_target performSelector:_action withObject:self]
);

warning:performSelector may cause a leak because its selector的更多相关文章

  1. PerformSelector may cause a leak because its selector is unknown 解决方法

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3801030.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  2. performSelector may cause a leak because its selector is unknown

    转自:http://www.jianshu.com/p/6517ab655be7 问题 我在 ARC 模式下编译出了这个 warning: "performSelector may caus ...

  3. ios之"performSelector may cause a leak because its selector is unknown"警告原因及其解决办法

    问题描述 项目中使用到了从字符串创建选择器,编译时发现警告:"performSelector may cause a leak because its selector is unknown ...

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

    #define SuppressPerformSelectorLeakWarning(Stuff) \ do { \ _Pragma("clang diagnostic push" ...

  5. performSelector may cause a leak because its selector is unknown解决

    解决方法 SEL selector = NSSelectorFromString(@"applySketchFilter:"); IMP imp = [FWApplyFilter ...

  6. 《Effective Objective-C 2.0》摘要

    前一段时间将<Effective Objective-C 2.0>这本书浏览了一遍,说一下几个觉得比较有意思的知识点. 感觉这本书是ios开发必看的一本书,最基础的,以及稍微高阶一点的oc ...

  7. 【IOS 开发】Objective - C 面向对象高级特性 - 包装类 | 类处理 | 类别 | 扩展 | 协议 | 委托 | 异常处理 | 反射

    一. Objective-C 对象简单处理 1. 包装类 (1) 包装类简介 NSValue 和 NSNumber : -- 通用包装类 NSValue : NSValue 包装单个 short, i ...

  8. iOS 面试总结

    APP崩溃 启动秒退 在新 iOS 上正常的应用,到了老版本 iOS 上秒退最常见原因是系统动态链接库或Framework无法找到.这种情况通常是由于 App 引用了一个新版操作系统里的动态库(或者某 ...

  9. 【转】clang warning 警告清单(备查,建议直接command + F 速查 )

    Warning Message -WCFString-literal input conversion stopped due to an input byte that does not belon ...

随机推荐

  1. 编写更好的CSS

    编写好的CSS代码能提升页面的渲染速度.本质上,一条规则都没有引擎解析的最快.MDN上将CSS选择符归拆分成四个主要类别,如下所示,性能依次降低. ID 规则 Class 规则 标签规则 通用规则 对 ...

  2. sizeof学习理解

    以下内容转自: http://www.cnblogs.com/ComputerG/archive/2012/02/02/2335611.html 博问 闪存 首页 新随笔 联系 管理 随笔- 72  ...

  3. (4)用opengl读入off文件生成可执行文件把模型显示出来(未完待续)

    ·找了好几个程序,好像都达不到我的要求,去教程里看看吧! 在往上抛出了这问题,好几天才有人回答,我已经找到程序了 正好的他的分析对我分解程序很有用 这是一个难度比较高的 首先你要分析.off文件结构, ...

  4. Codeforces Round #335 (Div. 2) D. Lazy Student 贪心

    D. Lazy Student   Student Vladislav came to his programming exam completely unprepared as usual. He ...

  5. iftop 使用

    测试中常常发现服务器网卡打满,那么这些流量具体占用情况如何呢? 这个时候我们要使用iftop来看看,首先我们要安装: 一. 安装 首先安装libpcap,下载链接:http://www.tcpdump ...

  6. iOS多线程 GCD

    iOS多线程 GCD Grand Central Dispatch (GCD)是Apple开发的一个多核编程的解决方法. dispatch queue分成以下三种: 1)运行在主线程的Main que ...

  7. SPRING IN ACTION 第4版笔记-第十一章Persisting data with object-relational mapping-006Spring-Data的运行规则(@EnableJpaRepositories、<jpa:repositories>)

    一.JpaRepository 1.要使Spring自动生成实现类的步骤 (1)配置文件xml <?xml version="1.0" encoding="UTF- ...

  8. Centos环境下部署游戏服务器-软件安装

    这篇文章主要介绍一下游戏服务器需要安装的软件和需要修改的配置.现介绍下项目,本项目服务器端是c++ + mysql组合,客户端是as写的,需要安装的服务为Mysql,Php,Apache, 以及一个n ...

  9. Android中级之网络数据解析一之xml解析

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! --Comic Sans MS Xml解析具有跨平台性,语言无关性,易操作性,因此广受开发者的欢迎. ...

  10. 311. Sparse Matrix Multiplication

    题目: Given two sparse matrices A and B, return the result of AB. You may assume that A's column numbe ...