Should I free instance variables and properties in dealloc?

According to Apple's documentation on the Controller Life Cycle View, I noticed the following regarding the dealloc method:

Override this method only to perform any last-minute cleanup, view the controller class. Objects stored in instance variables and properties are automatically freed; You do not need to release them explicitly.

I have always been taught to invoke the release of instance variables and properties that I have in my controller dealloc method method.

The only exception that I knew about was using ARC, but ARC is not mentioned in this documentation.

Is it correct?

+4
source share
2 answers

Since the guide you recently published was updated, I am sure that it assumes that you are using ARC (you should do this if possible).

You are right, before ARC you had to free instance variables in the dealloc method (you can see this in old XCode templates in the dealloc App-Delegate). With ARC, this is automatically handled (as stated in this guide), therefore, except for special needs, the dealloc method is no longer used.

+9
source

Source: https://habr.com/ru/post/1399388/


All Articles