NSWindowController 和 NSWindow 的关系
[self.myWindowController showWindow:self];
#import "MainWindowController.h"
@interface AppDelegate ()
@property (nonatomic, strong) NSWindowController *myWindowController;
@property (nonatomic, strong) NSWindow *myWindow;
@end
@implementation AppDelegate
-(NSWindowController *)myWindowController{
if (!_myWindowController) {
_myWindowController = [[NSWindowController alloc]init];
_myWindowController.window = self.myWindow;
self.myWindow.windowController = _myWindowController;
}
return _myWindowController;
}
-(NSWindow *)myWindow{
if (!_myWindow) {
_myWindow = [[NSWindow alloc]initWithContentRect:CGRectMake(0, 0, 400, 300) styleMask:1 backing:2 defer:NO];
}
return _myWindow;
}
- (void)windowDidLoad {
[super windowDidLoad];
[self.myWindow makeKeyAndOrderFront:self];
}
-(void)dealloc{
NSLog(@"%s",__func__);
}
@end