• 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
Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting (not saving) NSPersistentDocument Metadata changes file Modification Date


  • Subject: Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 3 Nov 2010 22:00:43 -0700

In Core Data Programming Guide ▸ Using Persistent Stores ▸ Store Metadata, I read:

"Note that setting the metadata for a store does not change the information on disk until the store is actually
saved."

And indeed that is true.  So I add my metadata, in my document-saving method, *before* invoking NSPersistentDocument's -saveDocument: or saveDocumentAs:, which does the actual saving.

However, although the metadata does not get written to the disk by +[NSPersistentStoreCoordinator setMetadata:forPersistentStoreOfType:URL:error:], apparently the file modification time gets changed, because after doing so, and then invoking -saveDocument:, the dreaded warning sheet "This document's file has been changed by another application since you opened or saved it" shows its wretched face.

So, I do this:

• Read and remember the file's modification date (NSFileManager)
• Set the desired metadata
• Set the file's modification date back to the remembered value (NSFileManager)
• Invoke -saveDocument:

Voila - no more stupid warning sheet.

Why does +[NSPersistentStoreCoordinator setMetadata:forPersistentStoreOfType:URL:error:] change the file modification time given that, per documentation, it does not modify the file?

Is there a better way to do this?

_______________________________________________

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: Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
      • From: "Sean McBride" <email@hidden>
  • Prev by Date: Re: CALayer renderInContext: performance
  • Next by Date: Re: Set Icon For Document-Based Files
  • Previous by thread: Re: CALayer renderInContext: performance
  • Next by thread: Re: Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
  • Index(es):
    • Date
    • Thread