要让编译器识别子类化的NSWindow实例,需要按照以下步骤进行操作:
// MyCustomWindow.h
#import
@interface MyCustomWindow : NSWindow
@end
// MyCustomWindow.m
#import "MyCustomWindow.h"
@implementation MyCustomWindow
@end
// AppDelegate.m
#import "AppDelegate.h"
#import "MyCustomWindow.h"
@interface AppDelegate ()
@property (weak) IBOutlet MyCustomWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[self.window makeKeyAndOrderFront:nil];
}
@end
通过按照上述步骤进行操作,编译器将能够识别子类化的NSWindow实例,并且你可以在子类中添加自定义的行为和属性。