I have a controller class which spawns a window when a certain condition occurs. This window can be closed by the user, moved around or resiz开发者_高级运维ed.
Ideally, when this condition occurs, I'd like the window to re-open in the same spot the user closed it last time.
Looking for an elegant way to do this. Pointers (or references) will be most welcome.
Luckily, AppKit knows this is a common pattern and has provided -setFrameAutosaveName:
, which does this automatically for you. (If you're using NSWindowController
you'll want to call setShouldCascadeWindows:NO
, which will override this.)
精彩评论