Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I dealloc @property items?

The basic rule that I have been going by is "if I alloc, I dealloc," but is this an overly simple view?

like image 696
griotspeak Avatar asked Dec 09 '22 13:12

griotspeak


1 Answers

The rule is "if you invoke a method that starts with new or alloc, is called retain, or contains copy, then you must (auto)release". (Easy way to remember this is the acronym: "NARC")

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

[myProperty release];

in your dealloc method.

like image 171
Dave DeLong Avatar answered Dec 30 '22 12:12

Dave DeLong