I'm starting to use iOS5 and I've enabled ARC for my project. I have a class where on deallocation I save the state of that object.
-(void)dealloc { [self save]; [super dealloc]; }
However, under ARC, [super dealloc]
is not allowed? I thought that it was considered a bug if you don't invoke the dealloc method on the super class in this situation?
So what is the appropriate way to dealloc objects now?
Automatic Reference Counting manages object life cycles by keeping track of all valid references to an object with an internal retain count. Once all references to an object go out of scope or are cleared, and the retain count thus reaches zero, the object and its underlying memory is automatically freed.
Swift uses Automatic Reference Counting (ARC) to track and manage your app's memory usage. In most cases, this means that memory management “just works” in Swift, and you don't need to think about memory management yourself.
Automatic Reference Counting (ARC) is a memory management option for Objective-C provided by the Clang compiler. When compiling Objective-C code with ARC enabled, the compiler will effectively retain, release, or autorelease where appropriate to ensure the object's lifetime extends through, at least, its last use.
ARC in iOS 5 is under NDA. That said, judging from publicly available information at the official site of clang, you just don't write [super dealloc]
. That's generated automatically by the compiler. See the clause 7.1.2 of the specification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With