Re: Saving window and view state with NSDocument
Re: Saving window and view state with NSDocument
- Subject: Re: Saving window and view state with NSDocument
- From: Quincey Morris <email@hidden>
- Date: Mon, 21 Sep 2015 11:53:17 -0700
- Feedback-id: 167118m:167118agrif8a:167118sShSBAx2tQ:SMTPCORP
On Sep 21, 2015, at 11:09 , Kurt Sutter <email@hidden> wrote:
>
> I want the state information of the windows and views to be stored in the document so that the same windows and views reopen when the user opens the document.
>
> What is the best way to do that? I guess I have to take two steps:
>
> (a) collect that state information in dataOfType:error: and store it in the NSData object to be returned and
> (b) retrieve that data from the NSDocument in readFromData:ofType:error: and then somehow apply it in the NSDocument’s makeWindowControllers method.
You don’t mention OS X state restoration:
https://developer.apple.com/library/prerelease/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html <https://developer.apple.com/library/prerelease/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/StandardBehaviors/StandardBehaviors.html>
(under heading "Windows Are Restored Automatically”), but that sounds like what you’re looking for.
Note that state restoration is extremely badly documented in Apple’s documentation. You’ll need to sift through API for individual classes and protocols, and sometimes look at the Obj-C header comments, to get a reasonably complete picture of what’s going on.
There are probably some relevant WWDC videos, perhaps starting with "Resume and Automatic Termination in Lion” from 2011.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden