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 cycle” in ARC-enabled code
解决方法:
方法一:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:Api]]; __block ASIHTTPRequest *brRequest = request; [request setCompletionBlock:^{
id json = [NSJSONSerialization JSONObjectWithData:[brRequest responseData] options: error:Nil];
//NSLog(@"%@",json);
NSLog(@"completed"); }]; [request setFailedBlock:^{
NSLog(@"%@",[brRequest error]);
}]; [request startAsynchronous];
方法2:
// //方式二
// __weak ASIHTTPRequest *werRequest = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:api]];
// [werRequest setCompletionBlock:^{
// id json = [NSJSONSerialization JSONObjectWithData:[werRequest responseData] options:0 error:Nil];
// NSLog(@"%@",json);
//
// }];
//
// [werRequest setFailedBlock:^{
// NSLog(@"%@",[werRequest error]);
// }];
//
// [werRequest startAsynchronous];
xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code的更多相关文章
- 处理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 代码: ...
- 在block函数中规避错误信息 "capturing self strongly in this block is likely to lead to a retain cycle”
以形如 _fontValueChangedBlock = ^(){ [self.fontSmallButton addTarget:self action:@selector(btnFontSmall ...
- 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 ...
- 决绝Capturing 'demo' strongly in this block is likely to lead to a retain cycle
- (IBAction)onTest:(id)sender { BlockDemo *demo = [[BlockDemo alloc]init]; __weak typeof(BlockDemo) ...
- [ios2]警告:Block的Retain Cycle的解决方法 【转】
<span style="background-color: rgb(248, 248, 248); font-family: 'PT Sans', Geogia, Baskervil ...
- block没那么难(三):block和对象的内存管理
本系列博文总结自<Pro Multithreading and Memory Management for iOS and OS X with ARC> 在上一篇文章中,我们讲了很多关于 ...
- Block的Retain Cycle的解决方法
一个使用Block语法的实例变量,在引用另一个实例变量的时候,经常会引起retain cycle.这个问题在使ASIHTTPRequest的block语法的时候会时不时的碰到.这个问题困扰了我这个小白 ...
- 八.OC基础加强--1.autorelease的用法 2.ARC下内存管理 3.分类(category)4.block的学习
1.autorelease的用法 1.自动释放池及autorelease介绍 (1)在iOS程序运行过程中,会创建无数个池子,这些池子都是以栈结构(先进后出)存在的. (2)当一个对象调用auto ...
- block 在ARC和非ARC下的不同含义
Block的循环引用 对于非ARC下, 为了防止循环引用, 我们使用__block来修饰在Block中使用的对象: 对于ARC下, 为了防止循环引用, 我们使用__weak来修饰在Block中使用的对 ...
随机推荐
- 从零开始做SSH项目(一)
1.数据库脚本 用户表 CREATE TABLE `ybl`.`userinfo`( `id` INT NOT NULL AUTO_INCREMENT, `email` ) NOT NULL, `id ...
- 用Pandas获取商品期货价格并可视化
用Pandas获取商品期货价格并可视化 摘 要 1.用pandas从excel中读取数据: 2.用pandas进行数据清洗.整理: 3.用bokeh进行简单的可视化. 1.数据读取 本文主要是将获 ...
- 【模拟】Flo's Restaurant
[poj2424]Flo's Restaurant Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2960 Accept ...
- [bzoj1008](HNOI2008)越狱(矩阵快速幂加速递推)
Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 In ...
- mysql memory存储引擎简单测试
Auth: jin Date: 20140423 mysql> CREATE TABLE `t4` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` ...
- 推荐一套WPF主题皮肤
在CodePlex上发现了一套WPF的主题皮肤,直接应用于系统自带的控件,一共有四种配色方案,做得也还比较精致.感兴趣的朋友可以使用一下.点击下载 另外一套我比较喜欢的皮肤这里也推荐一下吧: ...
- 【Rocket MQ】RocketMQ 在windows7 64位安装使用 +RocketMQ管理界面的安装
参考地址:https://blog.csdn.net/yucaifu1989/article/details/80960018 参考地址:https://blog.csdn.net/u01204090 ...
- Anaconda安装Graphviz, mac下Graphviz安装, pcharm中调用pycharm, Graphviz典型例子
mac下的Graphviz安装及使用 2017年10月13日 13:30:07 阅读数:7495 一.安装 Graphviz http://www.graphviz.org/ mac用户建议直接用ho ...
- git log --oneline --graph的读法
星号表明这个提交所在的分支: 最左边的直线表示当前分支的历史状态,从图看,当前分支HEAD是master分支 :提交历史是:8cfbb25<--d486463<--a88c595<- ...
- pycharm的插件pylint报错:java.lang.Throwable: Write-unsafe context! Model changes are allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality stat
java.lang.Throwable: Write-unsafe context! Model changes are allowed from write-safe contexts only. ...