开发者社区> 问答> 正文

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

展开
收起
a123456678 2016-07-19 17:11:55 3928 0
2 条回答
写回答
取消 提交回答
  • 这是意味着有循环引用,建议在block外面声明__weak typeof(self) weakSelf = self; 然后在block里面使用weakSelf而不是self
    2019-07-17 19:58:36
    赞同 展开评论 打赏
  • 你把self转换一下加上block字段之后就不会被retain了

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

    2019-07-17 19:58:36
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Fighting Cybercrime: A Joint Task Force of Real-Time Data and Human Analytics 立即下载
The Leaky Pipeline Problem: Making your Mark as a Woman in Big Data 立即下载
Separating hot-cold data into heterogeneous storage based on layered compaction 立即下载