【发布时间】:2012-07-01 10:19:15
【问题描述】:
我对块和创建保留循环的可能性变得有点偏执。我正在使用UIAlertView 类的基于块的版本,它允许您使用块而不是委托方法。我使用了很多这样的 Alertviews,所以我经常调用实例方法来做很多繁重的工作。
我在方法someInstanceMethod 中所做的分配会导致保留循环吗?
(我正在使用 ARC 进行内存管理。)
__weak id weakSelf = self;
[doWorkAndThen:^{
[weakSelf someInstanceMethod];
}];
-(void) someInstanceMethod{
//will either of the assignments below cause a retain cycle?
self.iVar = @"data";
[self setIvar:@"data";
}
【问题讨论】:
标签: ios ios5 automatic-ref-counting objective-c-blocks