我使用的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
)爲單位。我應該這樣做後,默認禁用警告?
感謝您的澄清。我錯過了只有在存儲時才保留該塊。 – efpies
塊是「長壽命」意味着什麼?所有塊都有有限數量的代碼行,因此它最終會退出。 – Pwner