I’ve been replicating the NSDocument framework in Xojo in an attempt to handle Sandboxing better. Part of this is to use Apple’s NSWindowRestoration framework (Christian has been a big help with this and has included improvements to his MBS plugin). The key seems to be to obey if the user has NSQuitAlwaysKeepsWindows set or not.
I’ve been using NSUserDefaults to read this property (especially as the user can set it on a per application basis) and have discovered that it can one of 3 states.
#1 No value - the key doesn’t exist and at which point the app must obey ‘default’ behavior.
#2 True (or 1) - The key has been set and therefore the user wants to use persistence.
#3 False (or 0) - The key is set, and the user doesn’t want persistence.
The trouble is that the default behavior is actually different between Lion & Mountain Lion.
Lion - If the key isn’t present, use persistence.
Mountain Lion - if the key isn’t present, don’t use persistence.
Who knows what the default will be on 10.9?
Does anyone know of a proper API I can use to get a simple Yes or No answer, if not at least hopefully this information will be useful for other developers.
Another key to look for is “NSCloseAlwaysConfirmsChanges” on Mountain Lion, this seems to disable Auto Save in place, so that when the user closes the document it asks them if they want to save changes or not.