I have a Swift application that is launching a simple NSWindow
, like so:
func applicationDidFinishLaunching(notification: NSNotification!) {
let
I don't know if there is a better way, but the problem here is that when the AutosaveName is set in Interface Builder, and the Window is open via a Segue, the window is open at a predefined location and the frame is saved, overwriting the last saved frame...
If you have a predefined position to the center of the screen, each time the window will be open, it will appear in the center and the position will be saved.
To avoid this, I set the AutosaveName in the Window Controller (Not in IB), after restoring the saved Frame:
class MyWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
let thewindow = window as! NSWindow
/// restore position
thewindow.setFrameUsingName("MyWindow")
self.windowFrameAutosaveName = "MyWindow"
}
}