• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
seamlessly saving to a different file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

seamlessly saving to a different file


  • Subject: seamlessly saving to a different file
  • From: Steve Mills <email@hidden>
  • Date: Mon, 15 Jul 2013 09:38:14 -0500

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?

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



_______________________________________________

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


  • Follow-Ups:
    • Re: seamlessly saving to a different file
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: height of UITableView with exactly two rows
  • Next by Date: Re: Advanced Techniques
  • Previous by thread: EventKit calendarItemIdentifier and calendarItemExternalIdentifier
  • Next by thread: Re: seamlessly saving to a different file
  • Index(es):
    • Date
    • Thread