【发布时间】:2013-09-27 10:50:31
【问题描述】:
我使用 Xcode 5 并且有一些代码
@interface Controller {
__weak IBOutlet UIView *someView;
}
@implementation Controller {
- (void)doSomething
{
[UIView animateWithDuration:0.5 animations:^{
someView.hidden = YES;
}];
}
- (void)doSomething1
{
[UIView animateWithDuration:0.5 animations:^{
[self doSomething];
}];
}
为什么没有在那里抛出保留周期警告?我应该对self 使用弱引用每次我在块中使用self 吗?
我还启用了Implicit retain of self within blocks 警告,它给了我 100 个警告,并建议我在块中写入self->ivar.prop(而不是ivar.prop)。在默认情况下禁用该警告后我应该这样做吗?
【问题讨论】:
标签: objective-c memory-leaks objective-c-blocks retain-cycle