Re: Why should we set ivars to nil in dealloc?
Re: Why should we set ivars to nil in dealloc?
- Subject: Re: Why should we set ivars to nil in dealloc?
- From: "Clark Cox" <email@hidden>
- Date: Sun, 13 Apr 2008 14:57:52 -0700
On Sun, Apr 13, 2008 at 12:36 PM, stephen joseph butler
<email@hidden> wrote:
> On Sun, Apr 13, 2008 at 12:48 PM, Ferhat Ayaz <email@hidden> wrote:
>
> > 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?
>
>
> Usually it's not. For me, it's 100% a "best practices" thing. It never
> hurts, so why not get into the habit of doing it?
Because it doesn't help either. I have never run into a situation
where setting an instance variable to nil in a -dealloc has provided
any benefit. At best, it does nothing, and at worst, it masks other
errors in your code.
The only way that it could ever affect your code is if you are
accessing an ivar of an already-dealloc'ed object; in which case
setting the ivar to nil only hides this problem.
--
Clark S. Cox III
email@hidden
_______________________________________________
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