Re: Setting pointer to nil
Re: Setting pointer to nil
- Subject: Re: Setting pointer to nil
- From: Jim Correia <email@hidden>
- Date: Tue, 20 Dec 2005 21:46:57 -0500
On Dec 20, 2005, at 5:50 PM, Ricky Sharp wrote:
For example, the above could be rewritten to be:
- (void)dealloc
{
[self setManagedObjectContext:nil];
[self setPersistentStoreCoordinator:nil];
[self setManagedObjectModel:nil];
[super dealloc];
}
While there isn't anything universally wrong with using accessors
from dealloc to release your objects, it does require caution.
If your accessors do any work besides retain/copy/release - i.e. they
have side effects (such as broadcasting change notifications,
registering undo) - it may be undesirable or unwise to use them from
within dealloc.
Another concern is that if a subclass has overridden an accessor,
that subclass is now going to get a message in a partially
deallocated state (and may have dangling pointers if it did not zero
out all of its pointers after release in its dealloc method.)
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden