Consider that you are presenting only the view controller and not any related window controller you define if you use presentAsModalWindow(_ viewController: NSViewController)
The viewController is made the delegate and contentViewController of the window while it is shown
You could make the window customisations in viewWillAppear of your custom view controller
override func viewWillAppear() {
let closeButton = view.window?.standardWindowButton(.closeButton)
closeButton?.isHidden = true
}
In viewDidLoad
the window property will be still nil.
If you want to present your window controller do something like this triggered my your menu item.
@IBAction func showMyWindowController(sender:NSMenuItem){
let storyboard = NSStoryboard(name: "Main", bundle: nil)
let windowController = storyboard.instantiateController(withIdentifier: "MyWindowController") as! NSWindowController
windowController.showWindow(self)
}
Hope this helps