On Feb 16, 2017, at 10:09 , David Catmull <[email protected]> wrote:
> 
> I'm working on using encodeRestorableState/restoreStateWithCoder to save
> and restore the state of a window. (I'm doing this manually because I want
> to explicitly save my window state in the document and not just rely on the
> OS restoring its state as part of restoring the application state.)

It’s a while since I’ve had to wrestle with custom restoration, so maybe I’m 
missing something obvious, but I can’t quite come to grips with what you’ve 
said here.

On the face of it, if you’re saving the window state in the document, you 
should not be using window restoration *at all*. Instead, you should simply 
configure the window back to how/where it should appear as part of the document 
opening process, after creating the window controller and before showing the 
window — in an override of NSDocument’s “makeWindowControllers” probably.

If by "encodeRestorableState/restoreStateWithCoder” you mean the standard 
NSResponder methods, then the saved state is *not* saved in your document, and 
restoration likely happens — or at least starts — before your NSDocument 
instance exists. You then fall into a timing and state consistency hole (the 
window being restored is created early in app startup, the document information 
is available later), so I don’t find it entirely surprising that an error 
occurs.

If I’m off track here, can you clarify what you’re trying to do with the actual 
state restoration mechanism, if it’s not to save/restore its own state data?

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to