Hi all,

No formal documentation yet exists for the new NSDocument autosave
path. Well, really paths, because "autosave" actually refers to two
related but different things:

- The old-style periodic autosaving that is done to protect against crashing.
- The new behavior where the document is saved at certain key
intervals, including application quit.

Sussing out the new scheme has been straightforward, if time
consuming. I've built a pretty complicated OmniGraffle diagram that
describes the new world order: http://db.tt/gP2zi7j

But I just encountered something in the AppKit release notes that has
thrown me for a bit of a loop. In the section "Things to Watch For
When Enabling NSDocument Autosaving in Place" is the following
paragraph:

> • Overriding the various -write… methods
>
> During duplicating and reverting NSDocument may cause the current version of 
> the document, the one the user is looking at at that moment, to be preserved. 
> Doing this sometimes requires that the document's current contents be written 
> to disk. NSDocument does not invoke any of the -save… methods in that case. 
> Instead, it invokes -writeSafelyToURL:ofType:forSaveOperation:error:, passing 
> it a URL to a file that will become the preserved version, the file type that 
> [self autosavingFileType] returns, and NSAutosaveElsewhereOperation. Your 
> NSDocument subclass must write the entire contents of the document to that 
> file. You will probably not notice this if you are not overriding 
> -writeSafelyToURL:ofType:forSaveOperation:error:, you are correctly 
> overriding one of the simple writing methods, which are 
> -writeToURL:ofType:error:, -fileWrapperOfType:error:, and -dataOfType:error:, 
> and if -autosavingFileType always returns an appropriate value.

According to my diagram, new-style autosaves, explicit Cmd-S saves,
and periodic crash-protection autosaves all funnel through
-saveToURL:ofType:forSaveOperation:completionHandler:. Why doesn't
NSDocument also use this method for saving and reverting? Or does it?

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to