Re: Multiple windows from single nib-window object
Re: Multiple windows from single nib-window object
- Subject: Re: Multiple windows from single nib-window object
- From: Trygve Inda <email@hidden>
- Date: Mon, 14 Aug 2006 21:59:52 +0000
- Thread-topic: Multiple windows from single nib-window object
> On Aug 14, 2006, at 10:46, Trygve Inda wrote:
>
>> I have a window in my nib that I would like to open multiple copies
>> of and
>> then bind the elements to variables in an array. How can I open 3,
>> 4 or 5
>> separate windows from a single Window "template" in my nib?
>
> Create a (or modify your existing) class to be a subclass of
> NSWindowController. The change your constructor to look like this:
>
> - (id)init
> {
> if (self = [super initWithWindowNibName: @"YourWindowName"])
> {
> // do normal stuff that you'd normally do in init
> }
> return self;
> }
>
> Then in Interface Builder, drag this class in, and change the "File's
> Owner" custom class to your NSWindowController subclass. Set File's
> Owner's window outlet to be the window. Make sure you don't have any
> instances of the class instantiated in IB. All of your connections
> will now have to hook to File's Owner, not any instantiated version.
>
> Finally, in the code that you want to bring up these many windows
> (for the sake of this message, I'll just say there's a NSButton with
> this action method connected to it), use this code:
>
> - (IBAction)openNewWindow: (id)sender
> {
> YourNSWindowControllerSubclass *wc =
> [[YourNSWindowControllerSubclass alloc] init];
> [wc showWindow: self];
> }
>
> - Robert
So the window has to be in it's own nib? Is there any way to keep the window
in the app's main nib (which only has an AppController and a main window
currently.
Trygve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden