Re: NSWindowController and GC
Re: NSWindowController and GC
- Subject: Re: NSWindowController and GC
- From: Bryan Matteson <email@hidden>
- Date: Wed, 30 Sep 2009 21:18:51 -0500
Thank you Chris, Rob. I thought as much, but then I'm new to using GC.
I thought that because I was able to access the window controller
through the window that it was still reachable in the object graph.
You know, like
[[aSampleView window] windowController];
Thought that meant there was a pointer already stored in the window
instance, so unless the window was closed, it would not be collected.
Thank you for clearing that up, I think I'll go with the global
dictionary, as these window controller instances are created from
several different places.
-B
The right way is to make sure something in your program retains a
pointer to your window controller. Sometimes there will be an
obvious place, like a member of the object that created the window
controller. That is most typical. Worst case is you retain a pointer
in some global variable or similar, but that also has a greater
danger that you will forget to zero it out when you are finished
with it, and it won't get collected. Some of my temporary dialog box
controllers inherit from a class that puts itself in a global
dictionary when created, and removes itself when the window closes.
_______________________________________________
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