The only time you should call ever call -dealloc
in Objective-C is on the last line of your own -dealloc
method. This call should be [super dealloc];
. The proper way to dispose of an object is to send it a -release
message — -dealloc
will then be called if appropriate.
Now when I was first learning Cocoa, I sometimes disposed of objects by calling -dealloc
directly. This caused all sorts of problems. Truth be known, if I’ve been messing with several object’s -dealloc
methods, I’ll sometimes dyslex out and type dealloc
when I mean release
, just because it’s more fresh in my head. This is very rare, but it has happened once, and will happen again. I’m fallible like that. Murphy’s law tells us that I won’t catch it every time.
So I humbly propose that GCC should warn you if you use -dealloc
any way other then calling [super dealloc];
on the last line of your own -dealloc
methods.