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: Richard Charles <email@hidden>
- Date: Tue, 22 Sep 2015 10:45:43 -0600
> On Sep 21, 2015, at 12:09 PM, Kurt Sutter <email@hidden> wrote:
>
> I am trying to figure out how to store information about my windows and views in a document, and how to restore it.
Here is what I do in one application.
Override -[NSDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] to save extra information when saving the document. This app has a core data store so the extra information is stored there along with the document data.
Override -[NSDocument readFromURL:ofType:error:] to fetch the extra information when opening a document.
This app has very specific requirements about the extra information and what it does so it subclasses NSWindow and NSWindowController. I could never get the window and views to do or behave as required so subclassing gives you a much finer grain control over what happens.
All this should be done with caution. You need to make sure that what you are doing will be well received and beneficial to your user base, some of which are likely to be Mac fanatics. Just because you can do it or think of if it does not mean that you should.
--Richard Charles
_______________________________________________
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