• 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: NSOperation and NSAutoreleasePool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSOperation and NSAutoreleasePool
      • From: Kyle Sluder <email@hidden>
References: 
 >Fwd: NSOperation and NSAutoreleasePool (From: Aaron Wallis <email@hidden>)
 >Re: NSOperation and NSAutoreleasePool (From: Kyle Sluder <email@hidden>)
 >Re: NSOperation and NSAutoreleasePool (From: Aaron Wallis <email@hidden>)
 >Re: NSOperation and NSAutoreleasePool (From: Roland King <email@hidden>)
 >Re: NSOperation and NSAutoreleasePool (From: Aaron Wallis <email@hidden>)
 >Re: NSOperation and NSAutoreleasePool (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: NSOperation and NSAutoreleasePool
  • Next by Date: Re: NSOperation and NSAutoreleasePool
  • Previous by thread: Re: NSOperation and NSAutoreleasePool
  • Next by thread: Re: NSOperation and NSAutoreleasePool
  • Index(es):
    • Date
    • Thread