According to Apple's documentation on the View Controller Lifecycle I noticed the following regarding the dealloc method:
Override this method only to perform any last-minute cleanup of your view controller class. Objects stored in instance variables and properties are automatically released; you do not need to release them explicitly.
I've been taught always to call release on instance variables and properties that I own in my view controller's dealloc method.
The only exception I was aware of is when using ARC but it does not mention ARC in this documentation.
Is this correct?
Since the guide you posted was updated recently, I'm pretty sure that it assumes you're using ARC (you should do that, after all, if possible).
You're correct, before ARC, you had to release your instance variables in the dealloc
method (you can see that in the old XCode templates in the dealloc
of the App-Delegate). With ARC, this gets handled automatically (as this guide says), so except for special needs, the dealloc
method is not used anymore.
As JiaYow mentions, that guide has been updated to ARC. Here you can find the Legacy guide for view controllers: https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerPGforiOSLegacy/BasicViewControllers/BasicViewControllers.html#//apple_ref/doc/uid/TP40011381-CH101-SW1
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