Re: NSWindowController and GC
Re: NSWindowController and GC
- Subject: Re: NSWindowController and GC
- From: Rob Keniger <email@hidden>
- Date: Thu, 1 Oct 2009 09:41:22 +1000
On 01/10/2009, at 9:20 AM, Bryan Matteson wrote:
I was just reminded of something. I use GC in my app, and unless I
specifically disable collection for a window controller, it's
destroyed as soon as it loses key. I solved it by setting the
controller as the delegate of the window, disabling collection for
the window controller in windowDidLoad, and re-enabling it in
windowWillClose:. Is there another way?
Disabling collection for the window controller in this way is a bit of
a hack. With Garbage Collection, you need to make sure you have a
strong reference to the window controller somewhere. This generally
means making the window controller an ivar of another object, e.g.
your NSDocument instance.
What object creates your window controller in the first place? That's
probably the object that needs to hang on to it.
--
Rob Keniger
_______________________________________________
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