V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · Oct 14, 2015 · 2692 views
    This topic created in 3849 days ago, the information mentioned may be changed or developed.
    -(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 replies    2015-10-15 01:45:53 +08:00
    expkzb
        1
    expkzb  
       Oct 14, 2015
    是不是单例的问题
    siroccoicode
        2
    siroccoicode  
       Oct 15, 2015
    [FZoneHttpsOnServers sharedInstance]这个对象是不是持有该 block 的强引用?如果有的话,那确实会引起循环引用。你需要使用_weak FZoneHttpsOnServers * instance=[FZoneHttpsOnServers sharedInstance];而不是直接使用那个单例。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5913 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 02:54 · PVG 10:54 · LAX 19:54 · JFK 22:54
    ♥ Do have faith in what you're doing.