I’m new iOS development. Do I still need to release my properties in dealloc in iOS 6?
If not, how are my retained properties released? Is it done automatically?
Need some guidance on this. Sorry if this is a stupid question..
For example, when i do this:
- (void)dealloc
{
[super dealloc];
}
@end
I get a message similar to:
ARC forbids explicit message send of 'dealloc'
The answer is yes, reference counted memory management is still being used and the methods
retain,release,autoreleaseanddeallocare still in use.The question you need to ask is: “Do I need to use them?”
That answer depends on whether or not you have ARC enabled. ARC stands for Automatic Reference Counting and has been enabled by default in new iOS projects since iOS 5. ARC is a feature of the LLVM compiler and automatically adds the required retain/release/autorelease method calls to your code based on well known cococa programming conventions.
The reason the compiler tells you that ‘ARC forbids explicit messages.. etc’ is because it’s managing those calls for you – and it’s an all or nothing deal. ARC manages all the memory management, or none of it.
ARC can be enabled or disabled on a per project, or per file basis. ARC enabled code is compatible with Non ARC enabled code.
I would recommend you read the Transitioning to ARC Release Notes if you’re keen to see what ARC is doing for you.
Then I’d watch all of the Automatic Reference counting videos from developer.apple.com/videos.
Finally, if you’re up for it read through the official LLVM documentation on ARC.