• 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
Setting pointer to nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting pointer to nil


  • Subject: Setting pointer to nil
  • From: Jeff LaMarche <email@hidden>
  • Date: Tue, 20 Dec 2005 17:39:57 -0500

I've noticed that with Xcode 2.2, the Core Data Application template has been updated. The new application delegate class template been given a new dealloc method:

- (void) dealloc
{
[managedObjectContext release], managedObjectContext = nil;
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
[managedObjectModel release], managedObjectModel = nil;
[super dealloc];
}

I've never seen pointers set to nil like this in Objective-C. I don't recall any of the books I've got recommending doing this in a dealloc. I HAVE seen it done a lot in Java to blue in the garbage collector to the fact that you're done with an object.

Now that I see it, it does seem like a good idea - it seems like this practice would prevent sending messages to released objects, instead just sending a harmless message to nil (although it could potentially mask problems in some cases), but I can't help but wondering if this isn't the first sign that Apple's planning on giving us an Objective- C garbage collector at some point.

Jeff
_______________________________________________
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
  • Follow-Ups:
    • Re: Setting pointer to nil
      • From: John Stiles <email@hidden>
    • Re: Setting pointer to nil
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: NSSpeechSynthesizer leaking
  • Next by Date: Re: Setting pointer to nil
  • Previous by thread: NSManagedObjectID best practices?
  • Next by thread: Re: Setting pointer to nil
  • Index(es):
    • Date
    • Thread