NSWindow recoverable does not always work

I checked the restored option on my NSWindow. When I move the application and change its size and close / open the application, it sets the size and position of the window to the last size and position

but this does not happen on every computer where I test it. this only happens with a few computers

they don’t have any special settings regarding resumes.

Does anyone have any experience?

+6
source share
3 answers

But this does not happen on every computer where I test it. This only happens with multiple computers. They have no special settings regarding resumes.

Actually, this is so. Take a look at System Preferences> General Area. There should be an option "Close windows when exiting the application", which is responsible for the recovery behavior. In addition, in OS X Mountain Lion, Apple changed the default behavior, and now the application restores its state only when you exit Command-Option-Q.

So, you should probably check which version of OS X is installed on another Mac, and which preference is selected in the General panel. Hope this helps!

+22
source

One thing you should know is that checking the "Restorable" option in IB changes the window property. The actual restoration and conservation is in your hands.

First, you must comply with the NSWindowDelegate protocol and implement -window:willEncodeRestorableState:state and -window:didDecodeRestorableState: methods that encode and decode your window properties (for example, your window frame, which you obviously get by calling [myWindow frame] ).

You also need to comply with the NSWindowRestoration protocol and implement +restoreWindowWithIdentifier:state:completionHandler: (make sure you set the class to the recovery class using the setRestorationClass method)

For more detailed information, you can visit this Apple Documentation here .

+1
source

Source: https://habr.com/ru/post/927175/


All Articles