以形如

       _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”的更多相关文章

  1. PHP中的错误信息

    PHP中的错误信息   php.ini中配置错误消息 在PHP4中,没有异常 Exception这个概念,只有 错误Error.我们可以通过修改php.ini 文件来配置用户端输出的错误信息. 在ph ...

  2. 未指定的错误,发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息。数据类型不被支持。

    未指定的错误,发生了一个 Oracle 错误,但无法从 Oracle 中检索错误信息.数据类型不被支持. 博客分类: 雅芳生涯 .Net VB C# OracleMicrosoftSecurity  ...

  3. 处理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 代码: ...

  4. 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 ...

  5. 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 ...

  6. [转]Jquery中AJAX错误信息调试参考

    下面是Jquery中AJAX参数详细列表: 参数名 类型 描述 url String (默认: 当前页地址) 发送请求的地址. type String (默认: "GET") 请求 ...

  7. 在ASP.NET 5中显示错误信息

    在 ASP.NET 5 中如果不进行显示错误信息的相关配置,在发生错误时,在浏览器中只能看到空白页面. 显示错误信息的配置方法如下: 1)在 project.json 中添加对 Microsoft.A ...

  8. SpringMVC+HibernateValidator,配置在properties文件中的错误信息回显前端页面出现中文乱码

    问题: 后台在springMVC中使用hibernate-validator做参数校验的时候(validator具体使用方法见GOOGLE),用properties文件配置了校验失败的错误信息.发现回 ...

  9. PHP编译过程中常见错误信息的解决方法

    在CentOS编译PHP5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决.以下是具体的一些解决办法: checking for BZip2 support… yes ch ...

随机推荐

  1. Importing Product Images on Magento

    Multiple product images of each type can be imported into Magento, and associated with a specific pr ...

  2. vultr优惠码ssd vps赠送50美金,长期有效

    vultr最新优惠码.vultr vps注册教程,是大家关心的问题.网上流传很多vultr vps优惠码,鱼龙混杂,难以判断.其实,获取vultr优惠赠送美元的方式很简单. 第一种,新用户使用绑定信用 ...

  3. String、StringBuffer和StringBuilder区别及性能分析

    1.性能比较:StringBuilder >  StringBuffer  >  String 2.String <(StringBuffer,StringBuilder)的原因 S ...

  4. 【IE6的疯狂之一】IE6中奇数宽高的BUG

    IE6真是太疯狂了.今天由于项目需要做了这么一个布局:一个外部的相对定位div,内部一个绝对定位的div(right:0), 如图: 可是在IE6下查看,却变成了right:1px的效果了: IE6还 ...

  5. easyui datagrid分页

    datagrid分页设置 pagination="true" 貌似是不行的!  只是显示分页工具栏 没有达到分页效果 前端 $(function (){ var p = $('#d ...

  6. Jquery 获取上传文件大小

    <input type="file" id="file1" /> <script> var size = $("#file1& ...

  7. php常用数学函数

    php常用数学函数1. bcadd 任意精度数的相加2. bcsub 任意精度数的减法3. bcmul 乘法, bcdiv除法 4. bcmod 取余数. (比%功能更强大)5. bcpow 幂函数运 ...

  8. installshield学习笔记

    看预定义常量的值:SprintfBox(INFORMATION,"","%d",变量值);     自定义常量:#define MAXCOUNT 1000;#d ...

  9. Samba: Server setup..

    To make samba shard folder permission clear, there are 3 kind of permission need to be paid attentio ...

  10. jqGrid使用整理

    jqGrid使用整理 jqGrid是一款处理表格展现的jQuery插件,支持分页.滚动加载.搜索.锁定.拖动等一系列对表格的常规操作.以下是最近项目中实践jqGrid的整理 1.引入到项目中来 jqG ...