Re: NSOperation and NSAutoreleasePool
Re: NSOperation and NSAutoreleasePool
- Subject: Re: NSOperation and NSAutoreleasePool
- From: Aaron Wallis <email@hidden>
- Date: Sat, 7 Mar 2009 17:31:34 +1100
Thanks for pointing that one out, but it wasn't the cause for my
problem.
As for retaining the delegate, originally I wasn't, I just took the
advice from Roland, but it doesn't break if I don't have it there :D
On 07/03/2009, at 5:27 PM, Graham Cox wrote:
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