Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Cocoa
final class WindowController: NSWindowController {
init() {
let window = NSWindow()
window.styleMask = [.closable, .miniaturizable, .resizable, .titled]
super.init(window: window)
self.shouldCascadeWindows = false
window.setFrameAutosaveName(String(describing: type(of:self)))
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override var contentViewController: NSViewController? {
didSet {
self.window?.setFrameAutosaveName(String(describing: type(of:self)))
}
}
}
class ViewController: NSViewController {
override func loadView() {
self.view = NSView()
}
override func viewDidLoad() {
super.viewDidLoad()
}
}
let windowController = WindowController()
windowController.contentViewController = ViewController()
windowController.showWindow(nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment