Possible Duplicates:
Why shouldn't I use Objective C 2.0 accessors in init/dealloc?
dealloc, use release or set to nil for properties?
Hi,
Apple usually release ivars in dealloc but is there anything wrong with nilling the properties in dealloc?
I mean instead of this:
- (void) dealoc(){
[myRetainedProperty release];
[super dealloc];
}
write code like this:
- (void) dealoc(){
self.myRetainedProperty = nil;
[super dealloc];
}
I know that it is one additional method call but on the other hand it is safer as it doesn't crashes when you change your property form retain
to assign
and forget to amend dealloc.
What do you think? Can you think about any other reason to use release instead of setting to nil besides performance?
UPDATE: It appeared that this question was a duplicate of "Why shouldn't I use Objective C 2.0 accessors in init/dealloc?".