V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
tunnyios
V2EX  ›  iDev

block 循环引用问题

  •  
  •   tunnyios ·
    chenzao1024 · 2015-10-14 11:59:42 +08:00 · 1999 次点击
    这是一个创建于 3089 天前的主题,其中的信息可能已经有所发展或是发生改变。
    -(void)getMyGroupList
    {
    __weak __typeof(self) weakSelf = self;
    [[FZoneHttpsOnServers sharedInstance] getMyGroupListOnMyServersSuccess:^(id info) {
    NSDictionary *dic = (NSDictionary *)info;
    if ([[FZoneUtility getString:dic[@"success"]] boolValue]) {
    NSLog(@"%@", [dic[@"obj"] class]);
    [weakSelf.dataArray setArray:dic[@"obj"]];
    // weakSelf.dataArray = [dic[@"obj"] mutableCopy];
    if (weakSelf.dataArray.count > 0) {
    }else{
    [weakSelf defultWithMyGroup:weakSelf.dataArray];
    }
    }else{
    [weakSelf defultWithMyGroup:nil];
    }
    [weakSelf.tableView reloadData];
    [weakSelf.tableView headerEndRefreshing];
    [HUD hide:YES];

    } failed:^(NSError *error) {
    [HUD hide:YES afterDelay:0.5f];
    [FZoneUtility showMessage:messageServerNoResponse target:weakSelf];
    [weakSelf.tableView headerEndRefreshing];
    [weakSelf defultWithMyGroup:weakSelf.dataArray];
    }];
    }

    这个方法有问题导致我控制器一直释放不了!!!求指导!
    2 条回复    2015-10-15 01:45:53 +08:00
    expkzb
        1
    expkzb  
       2015-10-14 15:18:25 +08:00
    是不是单例的问题
    siroccoicode
        2
    siroccoicode  
       2015-10-15 01:45:53 +08:00
    [FZoneHttpsOnServers sharedInstance]这个对象是不是持有该 block 的强引用?如果有的话,那确实会引起循环引用。你需要使用_weak FZoneHttpsOnServers * instance=[FZoneHttpsOnServers sharedInstance];而不是直接使用那个单例。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2783 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:52 · PVG 19:52 · LAX 04:52 · JFK 07:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.