ios block 重复引用
2016-03-22 14:09
417 查看
摘要: 为啥要 _weak typeof(self) weakSelf = self
仅是自己的理解 不保证正确 严谨性
需要 _weak typeof(self) weakSelf = self
例子
仅是自己的理解 不保证正确 严谨性
需要 _weak typeof(self) weakSelf = self
例子
@interface GoodsDetailController () @property(strong,nonatomic) UILabel *testBlockLabel; @property(strong,nonatomic) NSString *daCai; @end @implementation GoodsDetailController - (void)viewDidLoad { self.view.backgroundColor = [UIColor redColor]; self.testBlockLabel = [UILabel newAutoLayoutView]; [self.view addSubview:self.testBlockLabel ]; //这里 对label进行了引用 self.testBlockLabel .text = @"dddddddddddd"; [self.testBlockLabel autoCenterInSuperview]; __weak typeof(self) weakSelf = self; // addTapActionWithBlock (https://github.com/shaojiankui/iOS-Categories) 这里有很多好用的东西 [self.testBlockLabel addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) { self.daCai =@"这里会有警告"; weakSelf.daCai =@"这样就没有问题"; }]; } - (void)dealloc { NSLog(@"赵大财"); }
相关文章推荐
- iOS应用获取当前设备连接的wifi的名字
- IOS retain,copy,assign理解 区别 使用
- React Native(ios)项目中logo,启动屏设置
- iOS 9 新特性:开发者集合篇(不断更新中......)
- IOS学习之IOS端账号密码登入和后台校验方式
- iOS中传感器的基本使用
- iOS 崩溃错误分析
- iOS给客户打包ipa 文件
- iOS集成百度地图方法步骤
- ios开发杂项(基础性介绍等)
- 项目适配iOS9遇到的一些问题及解决办法(更新两个小问题)
- iOS图片拉伸技巧
- iOS 30多个iOS常用动画,带详细注释
- iOS 图片左右反转 反向
- iOS 宏(define)与常量(const)的正确使用
- iOS9.3
- iOS 导出 ipa 包时 三个选项的意思
- iOS开发 选择目录未找到
- iOS-AutoresizesSubviews 属性详解
- iOS 百度推送