IOS 代码块block :capturing self strongly in this block is 告警
来源:互联网 发布:java马尔可夫链 编辑:程序博客网 时间:2024/06/09 14:10
我们在代码块中使用对象的成员时(成员变量是属性strong,MRC估计是retain时效果一样,使用方法时也一样):
警告:
capturing self strongly in this block is likely to lead to a retain cycle
意思应该是block会retain一次,所以使用前最好 __block MyClass* bObject = self;
简单代码如下:__block LoginViewController * blockSelf = self; if (name ==nil || name.length<=3) { [self.alert addButton:@"OK" actionBlock:^(void) { [blockSelf.userNameField becomeFirstResponder]; }]; [self.alert showInfo:self title:@"信息不完整" subTitle:@"用户名长度必须大于3." closeButtonTitle:nil duration:0.0f ]; self.checkFormStatus = FALSE; self.alert = nil; return FALSE; }
代码里添加了
__block LoginViewController * blockSelf = self;
同事替换了之前的写法 self.userNameField 改成 blockSelf.userNameField
告警就木有了!
0 0
- IOS 代码块block :capturing self strongly in this block is 告警
- 在block代码块中使用self报警告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之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
- 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的问题
- Oracle触发器调用外部java
- hive 学习笔记(一)
- Framengs杂记一
- vm 10 +centos6.3 安装
- 论MySQL何时使用索引,何时不使用索引
- IOS 代码块block :capturing self strongly in this block is 告警
- 在Eclipse中使用Axis2插件自动生成WSDL文件
- POJ - 1177 Picture(线段树 扫描线 区间合并)
- 如何优化 Java 性能?
- mysql 的 find_in_set函数使用方法
- Android开发中SQLite在多线程并发访问的应用
- 堆和栈的区别(转过无数次的文章)
- iOS开发心得记录1
- CSS中关于触发BFC