但有些時候還是要在物件銷毀時去做一些處理,例如解決或等待相關的事件完成,就常常會寫這段:
- (void)dealloc
{
// do something ...
[super dealloc];
}
結果,Xcode 就噴這段訊息:
ARC forbids explicit message send of 'dealloc'
經 Transitioning to ARC Release Notes 文件查證:
You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC.
Custom dealloc methods in ARC do not require a call to [super dealloc] (it actually results in a compiler error). The chaining to super is automated and enforced by the compiler.
僅需改成這樣了:
- (void)dealloc
{
// do something ...
}
沒有留言:
張貼留言