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

Re: Why should we set ivars to nil in dealloc?


  • Subject: Re: Why should we set ivars to nil in dealloc?
  • From: "Jonathan del Strother" <email@hidden>
  • Date: Sun, 13 Apr 2008 19:00:47 +0100

On Sun, Apr 13, 2008 at 6:48 PM, Ferhat Ayaz <email@hidden> wrote:
> 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?

IMO, it's totally unnecessary.  Seems to be a cargo culting thing more
than anything else.
_______________________________________________

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

References: 
 >NSTextField vertical sizeToFit (From: Jeff <email@hidden>)
 >Why should we set ivars to nil in dealloc? (From: Ferhat Ayaz <email@hidden>)

  • Prev by Date: Some GC questions
  • Next by Date: Re: Window moved when dock appears.
  • Previous by thread: Why should we set ivars to nil in dealloc?
  • Next by thread: Re: Why should we set ivars to nil in dealloc?
  • Index(es):
    • Date
    • Thread