在block函数中规避错误信息 "capturing self strongly in this block is likely to lead to a retain cycle”
以形如
_fontValueChangedBlock = ^(){
[self.fontSmallButton addTarget:self action:@selector(btnFontSmallClicked) forControlEvents:UIControlEventTouchUpInside];
};
的代码为例,这个代码运行会报警告。"capturing self strongly in this block is likely to lead to a retain cycle”
要想消除这个警告,需要将代码改为如下形式:
__weak typeof(self) weakSelf = self; _fontValueChangedBlock = ^(){
typeof(weakSelf) __strong strongSelf = weakSelf;
[strongSelf.fontSmallButton addTarget:strongSelf action:@selector(btnFontSmallClicked) forControlEvents:UIControlEventTouchUpInside];
};
参考 http://stackoverflow.com/questions/16067712/avoiding-the-capturing-self-strongly-in-this-block-is-likely-to-lead-to-a-retai
在block函数中规避错误信息 "capturing self strongly in this block is likely to lead to a retain cycle”的更多相关文章
- PHP中的错误信息
PHP中的错误信息 php.ini中配置错误消息 在PHP4中,没有异常 Exception这个概念,只有 错误Error.我们可以通过修改php.ini 文件来配置用户端输出的错误信息. 在ph ...
- 未指定的错误,发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。
未指定的错误,发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息.数据类型不被支持. 博客分类: 雅芳生涯 .Net VB C# OracleMicrosoftSecurity ...
- 处理Block中的self问题(Capturing 'self' strongly in this block is likely to lead to a retain cycle)
警告:ARC Retain Cycle Capturing 'self' strongly in this block is likely to lead to a retain cycle 代码: ...
- capturing self strongly in this block is likely to lead to a retain cycle
一个用Block实例变量语法,当有一个参考的实例变量,常引起retain cycle. capturing self strongly in this block is likely to lead ...
- xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code
xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cyc ...
- [转]Jquery中AJAX错误信息调试参考
下面是Jquery中AJAX参数详细列表: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type String (默认: "GET") 请求 ...
- 在ASP.NET 5中显示错误信息
在 ASP.NET 5 中如果不进行显示错误信息的相关配置,在发生错误时,在浏览器中只能看到空白页面. 显示错误信息的配置方法如下: 1)在 project.json 中添加对 Microsoft.A ...
- SpringMVC+HibernateValidator,配置在properties文件中的错误信息回显前端页面出现中文乱码
问题: 后台在springMVC中使用hibernate-validator做参数校验的时候(validator具体使用方法见GOOGLE),用properties文件配置了校验失败的错误信息.发现回 ...
- PHP编译过程中常见错误信息的解决方法
在CentOS编译PHP5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决.以下是具体的一些解决办法: checking for BZip2 support… yes ch ...
随机推荐
- Chrome开发者控制台的这些功能你都知道吗?
Chrome内置了一些开发者工具,这些工具提供了很多的功能.今天,我们将会专注于JavaScript控制台. 在我编程的过程中,这个控制台为我提供了大量的帮助. 如果你正在电脑端阅读这篇文章,你可以在 ...
- 【Python】Python中对象管理与垃圾回收中两个很有意思的问题
再Python中是利用引用计数来实现对象管理和垃圾回收的,即其他对象引用该对象时候,其引用计数加1,反之减1,当引用计数为0时候,被垃圾收集器回收. Python解释器对对象以及计数器的管理分为以下两 ...
- 图片上传插件用法,net语法【二】
之前一直写过KindeEditor中的小控件作为单独上次,但业务要求需要另一种方式 现在改用ajaxfileupload.js试试,这个一百度 一.首页引用 <script src=" ...
- .net后台代码临时表创建
写法一: var dt = new DataTable(); dt.Columns.Add(new DataColumn("Id", System.Type.GetType(&qu ...
- wcf测试工具
WCF测试工具-WcfStorm WCF测试工具-WcfStorm http://www.wcfstorm.com/wcf/home.aspx WcfStorm is a dead-simple, ...
- Linux下Modules的概念及使用详解[转贴]
一.什么是 modules? modules 的字面意思就是模块,在此指的是 kernel modules:简单来说,一个模块提供了一个功能,如 isofs.minix.nfs.lp 等等.传统来讲, ...
- datatables.js 里面遇到的问题
1. 假如需要A行的data 和 B行的data 合并 在B行 data:name 在A行的 render:function(){ return data+full.name 此时返回的就是A+B ...
- jQuery(4)—— jQuery中的事件
jQuery中的事件 [加载DOM] 在常规的JavaScript代码中,通常使用window.onload方法,在jQuery中,使用的是$(document).ready()方法.极大地提高了we ...
- PHP中 post 与get的区别 详细说明
1.Get 方法通过 URL 请求来传递用户的数据,将表单内各字段名称与其内容,以成对的字符串连接,置于 action 属性所指程序的 url 后,如[url]http://www.jincaib.c ...
- 关于linux修改max user processes limits的问题
我们都知道,ulimit -u 可以设置max user processes limits,但是往往在设置的过程中,这样直接修改,不仅只能临时生效,重启之后又无效了,而且老是会失败. 而一般来说,修改 ...