Re: NSOperation and NSAutoreleasePool
Re: NSOperation and NSAutoreleasePool
- Subject: Re: NSOperation and NSAutoreleasePool
- From: Graham Cox <email@hidden>
- Date: Sat, 7 Mar 2009 17:27:17 +1100
On 07/03/2009, at 5:18 PM, Aaron Wallis wrote:
[delegate release];
delegate = tDelegate;
[delegate retain];
What if tDelegate == delegate?
You release delegate, which *may* dealloc it. Then you assign
tDelegate to it. If tDelegate == delegate (not uncommon that objects
are the same) then you've assigned a stale pointer. The following -
retain is too late.
The correct pattern is always "retain before release", i.e.:
[tDelegate retain];
[delegate release];
delegate = tDelegate;
Not sure if it has a bearing on your problem, but make sure the
obvious bugs are fixed first.
But in any case, you shouldn't be retaining your delegate. See the doc
link I posted a second ago.
--Graham
_______________________________________________
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