Should the elements dealloc @property?

The basic rule that I made is "if I set aside, I am dealloc", but is this a too simple representation?

+4
source share
2 answers

The rule is "if you call a method starting with new or alloc is called retain or contains copy , then you must (auto) release ". (A simple way to remember this abbreviation: "NARC")

If you declare @property as (retain) or (copy) , then you are responsible for the backup object, and you must do:

 [myProperty release]; 

in your dealloc method.

+13
source

Rule of thumb: (Almost) never call dealloc directly, use release . There are some exceptions. For example, in the object's dealloc method, you must call [super dealloc] .

+1
source

All Articles