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中使用的对 ...
随机推荐
- 234. Palindrome Linked List【Easy】【判断链表是否回文】
Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false ...
- 2018 ACM-ICPC 北京网络赛
Problem A 最短路,跑一下dij就可以了. Problem B Problem C 按照题意模拟,不过坑点很多 1.注意字典序: 2.注意挑战的时候失败的那个人要把当前所有桌子上的牌都拿走 P ...
- 最简单的Web Service实现
概述 这里提供一个最简单的Web Service的实现,基于JAX-WS.除了jdk不需要任何其他jar包,使用Eclipse提供的Web Services Explorer访问服务. 服务端的实现 ...
- git "Could not read from remote repository.Please make sure you have the correct access rights."解决方案
我们在使用git clone 或其他命令的时候,有时候会遇到这类问题,如图: fatal: Could not read from remote repository.Please make sure ...
- 【tomcat】获取访问者真实IP
1.直接访问tomcat的情况 通过下面这段代码可以获取: String ip = request.getHeader("x-forwarded-for"); if(ip == n ...
- Python开发基础-Day9-生成器、三元表达式、列表生成式、生成器表达式
生成器 生成器函数:函数体内包含有yield关键字,该函数执行的结果是生成器,生成器在本质上就是迭代器. def foo(): print('first------>') yield 1 pri ...
- 旺财C# .NET代码生成器之DTcms4/5代码批量生成功能
经近半年的实战积累.于2017年6月底,增加对第三方开源软件DTcms(4和5都支持)的代码生成支持. 可以一键生成的DTcms4/5代码如下:1.Model经典三层实体2.DAL经典三层数据库访问层 ...
- [BZOJ3622]已经没有什么好害怕的了(容斥DP)
给定两个数组a[n]与b[n](数全不相等),两两配对,求“a比b大”的数对比“b比a大”的数对个数多k的配对方案数. 据说做了这题就没什么题好害怕的了,但感觉实际上这是一个套路题,只是很难想到. 首 ...
- BZOJ 3127 [Usaco2013 Open]Yin and Yang(树点分治)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3127 [题目大意] 给出一棵01边权树,求存在多少条路径,使得路径上0和1的数量相同, ...
- 【枚举+贪心】POJ2718-Smallest Difference
[题目大意] 按升序输出几个不同的数字,任意组成两个数字,输出最小的差值. [思路] 虽然是在穷竭搜索的章节里找到的题目,但是我觉得不需要穷竭搜索,枚举一下就可以了,0MS.分为一下三种情况: (1) ...