Setting (not saving) NSPersistentDocument Metadata changes file Modification Date
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