How to restore windows to correct space and minimized state on launch?

I'm seeing many apps, when restoring their state from a previous launch, have trouble opening windows to the space and minimized state they were last.

What do I need to do so my AppKit app doesn't have this problem?

What I usually do is save the position and size in UserDefaults, then read it at opening and set the frame accordingly.

I gave details in this old thread.

https://forums.developer.apple.com/forums/thread/679764

@jpmhouston , this may be what you're looking for: restoreWindow(withIdentifier:state:completionHandler:)

It allows you to restore a minimized window.

How to restore windows to correct space and minimized state on launch?
 
 
Q