首页 > Capturing 'self' strongly in this block is likely to lead to a retain cycle

Capturing 'self' strongly in this block is likely to lead to a retain cycle

错误ID

ListViewController.m:135:10: Capturing 'self' strongly in this block is likely to lead to a retain cycle

开了ARC

    [_tableView setPullToRefreshHandler:^{
        [self dataDidRefresh:nil];
    }];

你把self转换一下加上block字段之后就不会被retain了

__block ViewController *controller = self;
[_tableView setPullToRefreshHandler:^{
[controller dataDidRefresh:nil];
}];


在ARC下不用__block 而是用 __weak 为了避免出现循环引用

【热门文章】
【热门文章】