On 15 Jul 2013, at 15:38, Steve Mills <[email protected]> wrote:

> We have a particular non-standard feature that will cause a document of an 
> old format and extension to automatically save to a new format and extension 
> when the user simply hits Save. The old file is moved to a backup folder 
> after the save is successful. (Yes, this feature is normally turned off, but 
> users having to batch convert thousands of documents only care about moving 
> ahead to the new version and leaving the old behind.)
> 
> I was able to find what seems to be the best place to tell the save to go to 
> the new extension, then do all the upkeep I thought I'd need to do afterward. 
> But, I'm still left with a dirty document that, when I hit Save again, tells 
> me "This document's file has been changed by another application since you 
> opened of saved it."
> 
> Here's the changes I've made to enable this feature:
> 
> In readFromURL:ofType:error:, setFileURL to the old file we read from, and 
> updateChangeCount:NSChangeDone.
> 
> In saveToURL:ofType:forSaveOperation:completionHandler:, remove the old 
> extension and add the new one to the url to write to, and pass it on to super.
> 
> In writeSafelyToURL:ofType:forSaveOperation:error:, move the old file to the 
> backup folder, setFileModificationDate to the mod date of the url new saved 
> file, and updateChangeCount:NSChangeCleared.
> 
> I think that's it. I even overrode saveDocument: so I could check 
> fileModificationDate and isDocumentEdited to make sure they're correct after 
> the entire operation is complete, and they are. Yet the close box remains 
> dirty and that message appears when I attempt to Save.
> 
> Any ideas?

NSDocument has an interesting method, 
-initForURL:withContentsOfURL:ofType:error:

Can you have document opening call this instead, or follow the same pattern, to 
achieve what you want?


_______________________________________________

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