Cocoa - Link IBOutlet for Nib Sharing

I have a nib file into which I load at a certain point in my application. Would it be legal for me to associate an NSWindow IBOutlet with my AppDelegate in the second window of the nib file? In other words, my IBOutlet does not connect to the xiM MainMenu file that Xcode creates by default. If it was legal, can I access the NSWindow frame and other functions?

Thank,

Kevin

+3
source share
3 answers

, . nib NSWindowController nib. AppDelegate NSWindowController, nib. , NSWindowController, , , .

@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
+6

File Owner . IB. [NSBundle loadNibNamed:owner:] .

+1

, , nib. , nib , , nib ( ).

0

Source: https://habr.com/ru/post/1792819/


All Articles