-
Notifications
You must be signed in to change notification settings - Fork 0
NSWindowController
Ken Harris edited this page Jul 23, 2020
·
2 revisions
If you subclass this and override func loadWindow()
, you must also override var windowNibName: NSNib.Name?
. Just return any (non-nil) string. It doesn't matter what. (NSViewController has no such requirement.)
A basic window controller, then, might look like:
class MyWindowController: NSWindowController {
override var windowNibName: NSNib.Name? { return "X" }
override func loadWindow() {
self.window = NSWindow(contentRect: NSRect(...),
styleMask: [.titled, .resizable, .miniaturizable, .closable],
backing: .buffered,
defer: false)
self.window?.title = "My Cool Window!"
}
override func windowDidLoad() {
self.contentViewController = MyViewController()
}
}