• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting pointer to nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Setting pointer to nil (From: Jeff LaMarche <email@hidden>)
 >Re: Setting pointer to nil (From: Ricky Sharp <email@hidden>)

  • Prev by Date: RE: XCode and subversion
  • Next by Date: NSBox
  • Previous by thread: Re: Setting pointer to nil
  • Next by thread: Re: Setting pointer to nil
  • Index(es):
    • Date
    • Thread