Re: NSWindowController, owner, "primary window"...
Re: NSWindowController, owner, "primary window"...
- Subject: Re: NSWindowController, owner, "primary window"...
- From: Gerd Knops <email@hidden>
- Date: Wed, 20 Aug 2008 14:13:39 -0500
On Aug 20, 2008, at 1:57 PM, Ken Thomases wrote:
On Aug 20, 2008, at 1:39 PM, Gerd Knops wrote:
I have a NSWindowController subclass managing a window and some
functionality in that window. Now at some point I need to display a
sheet, which is a window in a different nib.
I'd like to use another NSWindowController to load that nib file,
mainly so it will take care of (eg release) all the top level
objects in that second nib.
The bindings in the second nib need to access objects in my above
mentioned NSWindowController subclass, so I'd like that to be the
owner. Now when I instantiate the second NSWindowController using
'initWithWindowNibName:owner:', what do I do with the window
containing the sheet? I can't hook it up to the file's owner window
outlet, as that is already in use for the primary window.
So I basically have no (elegant) way of telling the second window
controller what it's window is, or am i missing something? The
NSWindowController has this vague notion of "primary window", but
doesn't really explain what happens when
'initWithWindowNibName:owner:' is used.
Is there some magic that allows 'initWithWindowNibName:owner:' to
figure out what the window is? Or does one have to use 'setWindow:'
to set the window when the above initializer is used?
It's very possible that your approach can be made to work. However,
at first blush, I'd do it a different way. I'd let the sheet
controller be the file's owner of the sheet nib. I'd add a property
to the sheet controller class (NSWindowController subclass) which
refers back to the master window controller (or its model object
graph). Then, I'd bind through that property of file's owner.
That'd work, but I'd have to subclass NSWindowController for that so I
can add that property. Seemed to me that the above would not be an
uncommon pattern and there ought to be a more elegant way that I might
have missed.
Thanks
Gerd
_______________________________________________
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