• 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
Why should we set ivars to nil in dealloc?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why should we set ivars to nil in dealloc?


  • Subject: Why should we set ivars to nil in dealloc?
  • From: Ferhat Ayaz <email@hidden>
  • Date: Sun, 13 Apr 2008 19:48:03 +0200

I see in some Apple's Cocoa examples that ivars are set to nil in the dealloc method. The auto generated Core Data AppDelegate for new projects is doing this for each ivar. Here is a simple example:

- (void)dealloc {
    [appointments release];
    appointments = nil;
   [super dealloc];
}

why is it necessary to set the variable appointments (for instance) to nil in this example? Should we do this for each variable? When have we to do this?
Thanks,


Ferhat




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Why should we set ivars to nil in dealloc?
      • From: "stephen joseph butler" <email@hidden>
    • Re: Why should we set ivars to nil in dealloc?
      • From: Jerry Krinock <email@hidden>
    • Re: Why should we set ivars to nil in dealloc?
      • From: j o a r <email@hidden>
    • Re: Why should we set ivars to nil in dealloc?
      • From: "Jonathan del Strother" <email@hidden>
References: 
 >NSTextField vertical sizeToFit (From: Jeff <email@hidden>)

  • Prev by Date: Re: HUD-style panel controls?
  • Next by Date: Window moved when dock appears.
  • Previous by thread: Re: NSTextField vertical sizeToFit
  • Next by thread: Re: Why should we set ivars to nil in dealloc?
  • Index(es):
    • Date
    • Thread