Last active
May 15, 2019 15:59
-
-
Save krzyzanowskim/a16567e897455dd4471b27b78165d581 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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