1

despite no change to my application

programmatically trigering autosave for the window's frame and content size only works usualy once,

I tried differant combination like moving the window around and then cloisng it manualy and yet I still get the same result

I then have to make a new autosave name and then sometimes it works and sometimes it doesn't here's my code

    view.window?.contentMinSize = NSSize(width: 310, height: 180) //Sets the view window minimum size.
    view.window?.setContentSize(NSSize(width: 510, height: 233)) //Sets the view window normal size.
    view.window?.isRestorable = true
    view.window?.setFrameUsingName(NSWindow.FrameAutosaveName(rawValue: "autosaveformyapp"))
    view.window?.titleVisibility = .visible
    view.window?.titlebarAppearsTransparent = true
    view.window?.hasShadow = true
    view.window?.makeKeyAndOrderFront(nil)
    view.window?.initialFirstResponder = view

update: I also tried to place the auto save line at differant place like before setting the window size but same result of it only working 1 time and then not working anymore

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    Method `setFrameUsingName`: "Sets the window’s frame rectangle by reading the rectangle data stored under a given name from the defaults system.". Property `frameAutosaveName`: "The name used to automatically save the window’s frame rectangle data in the defaults system.". Do you set this property? – Willeke Dec 04 '17 at 15:47
  • in my xcode project i set the autosave field to blank(nothing in it) because i want to handle it all programaticly if possible – balkon deremy Dec 04 '17 at 15:50
  • 1
    That isn't autosave. Do you save the frame? – Willeke Dec 04 '17 at 15:56
  • ok i was able just now to make it work with view.window?.windowController?.windowFrameAutosaveName = NSWindow.FrameAutosaveName(rawValue: "autosaveformyapp") but thats only for the frame what if i want to save the content size? – balkon deremy Dec 04 '17 at 16:09
  • just checking agian, and im runing into the same problem it saves the window 2-3 times and then stops working alltogether and wont work even with a new save name – balkon deremy Dec 04 '17 at 16:51
  • 1
    Related question: [NSWindowController Autosave using Storyboard](https://stackoverflow.com/questions/25150223/nswindowcontroller-autosave-using-storyboard) – Willeke Dec 05 '17 at 20:59

0 Answers0