Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
- Subject: Re: Releasing ivars in -didTurnIntoFault. Should set to nil?
- From: "Sean McBride" <email@hidden>
- Date: Wed, 12 Aug 2009 16:06:42 -0400
- Organization: Rogue Research Inc.
On 8/12/09 11:41 AM, Jerry Krinock said:
>I release a "regular" instance variable in my managed object's -
>didTurnIntoFault, and discovered that this was causing a crash
>sometime after an undo. In searching code on the internet I see that
>others have reported such crashes. I solved the problem by setting
>the instance variable to nil:
>
>- (void)didTurnIntoFault {
> [childrenTemp release] ; childrenTemp = nil ;
>
> [super didTurnIntoFault] ;
>}
>
>Now I understand that if nilling an instance variable after releasing
>it is done in -dealloc, it is papering over other memory management
>problems and is therefore bad programming practice. But I believe
>that this practice is OK in -didTurnIntoFault because, particularly
>when Undo is involved, -didTurnIntoFault may be invoked more than once
>on an object. Therefore nilling after releasing in -didTurnIntoFault
>is recommended.
>
>Does anyone disagree?
I made that discovery a few months back too, and I agree with your
reasoning and conclusions. I also asked an Apple guy at WWDC and he
concurred too.
hth,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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