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.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to