【发布时间】:2016-09-01 09:40:45
【问题描述】:
我在反应性可可块中使用 ivar,设置weakify(self) 和strongify(self) 以打破保留循环。但是当我运行代码时,它会导致内存泄漏,控制器不会调用dealloc 方法。如果我将 ivar 更改为属性,它运行正确。我对此感到很困惑,并搜索了很长时间。请告诉我为什么。
- (void)viewDidLoad {
[super viewDidLoad];
...
@weakify(self);
[RACObserve(self, something) subscribeNext:^(id x) {
@strongify(self);
[_button setBackgroundColor:[UIColor redColor]];
}];
}
- (void)dealloc {
}
【问题讨论】:
标签: ios objective-c memory-leaks reactive-cocoa retain-cycle