Re: Help "duplicating\spawning" a window
Re: Help "duplicating\spawning" a window
- Subject: Re: Help "duplicating\spawning" a window
- From: Ondra Cada <email@hidden>
- Date: Wed, 14 Nov 2001 11:19:30 +0100
Graham,
>
>>>>> Graham Wihlidal (GW) wrote at Wed, 14 Nov 2001 02:04:56 -0700:
GW> I have a window (NSWindow *gSessionWin) which is declared inside the
GW> header of a class and this variable is automatically linked to a
GW> particular window (an outlet) in IB. It is a window that must be
GW> spawned frequently (not one instance, but can create new documents of
GW> the same window, etc...)
The recommended (and in my experience really quite conveninent) way is to
place such a window into a NIB, and load the NIB whenever you need a new
instance.
You can do that "manually" in code like
@interface SomeController {
IBOutlet *theWindow; // to be connected to the window in NIB,
SomeController as File's Owner
}
-loadNewWindow;
@end
@implementation SomeController
-loadNewWindow {
if (![NSBundle loadNibNamed:@"Name of the NIB with the window" owner:self])
[NSException raise:@"application messed up" format:@"can't load the NIB"];
// OK, new window is loaded and bound to the outlet
[theWindow makeKeyAndOrderFront:self];
}
@end
I would guess though that for your needs it might be more convenient to use
the library code (which does this and much more) of the NSDocument suite --
check it in docs.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc