• 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: NSWindowController subclasses, and retain cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController subclasses, and retain cycles


  • Subject: Re: NSWindowController subclasses, and retain cycles
  • From: Jonathan Taylor <email@hidden>
  • Date: Thu, 24 May 2012 16:52:57 +0100

On 24 May 2012, at 16:27, Kyle Sluder wrote:
>> 1. If I do not set B's pointer to A, both A and B are deallocated correctly
>> 2. If instead I set B's pointer to A, but reset it to nil just before B is closed, both A and B are deallocated correctly
>> 3. If instead B still has a live pointer to A when B is closed, this should be autoreleased by the runtime, which it is. However, A never gets deallocated.
>
> If A somehow has a chain of retains that keeps B alive, #3 is wrong. Your approach with #2 seems sensible.

Thankyou all three for your replies. [I am not using ARC as this must run on Snow Leopard, incidentally].

Having done some playing around with trivial test cases, it appears that I have completely misunderstood a basic concept of properties - apologies for wasting your time. I had always thought that if I declare a property as follows:

@property (retain) MyProgressWindow * progressObject;
...
@synthesize progressObject = _progressObject;

then if that property has a non-nil value at the point that the instance is deallocated, a release would be sent. That had always struck me as the "obvious" behaviour, but it appears that this does not happen. I am sure there is a good reason for that! Not sure how I have managed to go this long without spotting that I am wrong here. Seems a bit of a pain to have to go through setting everything to nil in the dealloc method (which I would otherwise not have to even implement at all in many cases), but looks like that's what I need to do...

Cheers
Jonny
_______________________________________________

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

References: 
 >NSWindowController subclasses, and retain cycles (From: Jonathan Taylor <email@hidden>)
 >Re: NSWindowController subclasses, and retain cycles (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: NSWindowController subclasses, and retain cycles
  • Next by Date: Re: stringWithFormat / Rendering Text (iOS)
  • Previous by thread: Re: NSWindowController subclasses, and retain cycles
  • Next by thread: Re: NSWindowController subclasses, and retain cycles
  • Index(es):
    • Date
    • Thread