I have a nib file in which I load at a certain point in my application. Would it be legal for me to link a NSWindow IBOutlet from my AppDelegate to the 2nd nib file's window? In other words, my IBOutlet is not being connected to the MainMenu xib file that Xcode creates on default. If this was legal, can I have access to the NSWindow's frame and other features?
3
votes
3 Answers
6
votes
Yes you can do that. In your second nib file, I would use a NSWindowController as the file's owner to the nib. Then in your AppDelegate, create an instance of the NSWindowController and then load the nib. From there, you can inspect the properties of the window owned by NSWindowController or do whatever you want with the window.
Here is an example
@interface MyAppDelegate : NSObject
{
NSWindowController *myWindowController;
}
@end
@implementation MyAppDelegate
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
myWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MySecondWindow"];
[[myWindowController window] center];
[[myWindowController window] makeKeyAndOrderFront:self];
}
@end
1
votes