Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Reference Counting (ARC) says that invoking [super dealloc] is forbidden...what is the alternative?

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?

like image 427
Tim Reddy Avatar asked Jun 30 '11 15:06

Tim Reddy


People also ask

How does automatic reference Counting work?

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.

What is reference Counting in Swift?

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.

What is OBJC arc?

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.


1 Answers

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.

like image 119
Yuji Avatar answered Sep 20 '22 05:09

Yuji