Capturing self strongly in this block is likely to lead to retain cycle
来源:互联网 发布:展动力怎么样 知乎 编辑:程序博客网 时间:2024/06/08 17:21
这是在block里产生了循环引用
解决的办法是 创建一个本地变量 指向 自己(self).
例如:_items 实际上是 self->items,
_block 对象在创建的时候会被retain一次
改成:
__block ViewController *blockSelf = self;
_block = ^{
[blockSelf->_items addObject:@"Hello!"];
};
再例如在MJRefresh里用代码块创建刷新
- (void)addheaderRefresh {
__unsafe_unretained typeof(self) vc = self;
[self.tableView addHeaderWithCallback:^{
[vc.fakeData removeAllObjects];
for (int i = 0; i<3; i++) {
[vc.fakeData insertObject:MJRandomData atIndex:0];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[vc.tableView reloadData];
[vc.tableView headerEndRefreshing];
});
} dateKey:@"table"];
[self.tableView headerBeginRefreshing];
}
加红色的一句意义同上。
- 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 retain cycle 解决方案
- 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
- 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
- Capturing self strongly in this block is likely to lead to retain cycle解决方案
- Capturing self strongly in this block is likely to lead to retain cycle
- Capturing 'self' strongly in this block is likely to lead to a retain cycle [duplicate]
- 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
- 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 retain cycle的问题
- Capturing 'self' strongly in this block is likely to lead to a retain cycle [duplicate]
- iOS之Block报错:capturing self strongly in this block is likely to lead to a retain cycle
- iOS之Block报错:capturing self strongly in this block is likely to lead to a retain cycle
- iOS--错误集锦--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 [duplicate]
- Emacs 设置 Python 编辑模式下的自动补全
- Android系统自带样式(@android:style/) (转)
- Path动画--书写文字的动画实现
- 敏捷开发之Scrum扫盲篇
- eclipse连接hadoop报错Unknown protocol to job tracker: org.apache.hadoop.hdfs.protocol.ClientProtocol
- Capturing self strongly in this block is likely to lead to retain cycle
- SSH项目中,hql语句和sql语句的区别?
- Javad的Validator框架概述
- php中break,continue,exit的使用与区别
- eclipse 打点.不出提示(alt+/不出提示 )
- (转)MapReuce 编程总结-多MapReduce执行
- 幻方解法之Louberel法生成奇阶幻方
- Unix 网络编程(一)- 你的第一个socket程序“Daytimetcp”
- android 数据存储操作3:文件读写