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];

参考:http://stackoverflow.com/questions/7205128/fix-warning-capturing-an-object-strongly-in-this-block-is-likely-to-lead-to-a

xcode arc 下使用 block警告 Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code的更多相关文章

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

  2. 在block函数中规避错误信息 "capturing self strongly in this block is likely to lead to a retain cycle”

    以形如 _fontValueChangedBlock = ^(){ [self.fontSmallButton addTarget:self action:@selector(btnFontSmall ...

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

  4. 决绝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) ...

  5. [ios2]警告:Block的Retain Cycle的解决方法 【转】

    <span style="background-color: rgb(248, 248, 248); font-family: 'PT Sans', Geogia, Baskervil ...

  6. block没那么难(三):block和对象的内存管理

    本系列博文总结自<Pro Multithreading and Memory Management for iOS and OS X with ARC> 在上一篇文章中,我们讲了很多关于 ...

  7. Block的Retain Cycle的解决方法

    一个使用Block语法的实例变量,在引用另一个实例变量的时候,经常会引起retain cycle.这个问题在使ASIHTTPRequest的block语法的时候会时不时的碰到.这个问题困扰了我这个小白 ...

  8. 八.OC基础加强--1.autorelease的用法 2.ARC下内存管理 3.分类(category)4.block的学习

    1.autorelease的用法   1.自动释放池及autorelease介绍 (1)在iOS程序运行过程中,会创建无数个池子,这些池子都是以栈结构(先进后出)存在的. (2)当一个对象调用auto ...

  9. block 在ARC和非ARC下的不同含义

    Block的循环引用 对于非ARC下, 为了防止循环引用, 我们使用__block来修饰在Block中使用的对象: 对于ARC下, 为了防止循环引用, 我们使用__weak来修饰在Block中使用的对 ...

随机推荐

  1. 345. Reverse Vowels of a String【Easy】【双指针-反转字符串中的元音字符】

    Write a function that takes a string as input and reverse only the vowels of a string. Example 1: In ...

  2. Master定理学习笔记

    前言 \(Master\)定理,又称主定理,用于程序的时间复杂度计算,核心思想是分治,近几年\(Noip\)常考时间复杂度的题目,都需要主定理进行运算. 前置 我们常见的程序时间复杂度有: \(O(n ...

  3. Codeforces Round #426 (Div. 2) D The Bakery(线段树 DP)

     The Bakery time limit per test 2.5 seconds memory limit per test 256 megabytes input standard input ...

  4. getResourceAsStream 地址

    getResourceAsStream ()返回的是inputstream getResource()返回:URL Class.getResource("")    返回的是当前C ...

  5. Sass和Compass的安装

    Sass和Compass都是基于Ruby编程语言的命令行工具.要使用它们,你首先需要在电脑中安装Ruby,并对电脑的命令行操作有一个基本的理解.Sass和Compass可以安装在Windows.Mac ...

  6. 【BZOJ 3238】【AHOI 2013】差异

    http://www.lydsy.com/JudgeOnline/problem.php?id=3238 后缀数组裸题但是\(5\times 10^5\)貌似常数有点大就过不了?(我的sa常数那么大想 ...

  7. 【UOJ #198】【CTSC 2016】时空旅行

    http://uoj.ac/problem/198 (先补一下以前的题解) 这道题5分暴力好写好调,链上部分分可以用可持久化线段树,每次旅行\(x\)值相同的可以用标记永久化线段树.我还听到某些神犇说 ...

  8. hdu 4055 Number String (基础dp)

    Number String Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  9. BZOJ 1982 [Spoj 2021]Moving Pebbles(博弈论)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1982 [题目大意] 两个人玩游戏. 每次任选一堆,首先拿掉至少一个石头, 然后移动任意 ...

  10. 【枚举】XVII Open Cup named after E.V. Pankratiev Stage 4: Grand Prix of SPb, Sunday, Octorber 9, 2016 Problem D. Cutting Potatoes

    题意:有n个土豆,每个有体积V(i),你可以将每个土豆等分为不超过K份,问你最大块和最小块比值最小为多少. 直接枚举切法,只有n*K种,然后保证其为最大块,去算其他块的切法,即让其他块切得尽可能大即可 ...