Following the advice in
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5
regarding storage of BLOBs, I've chosen to store binary data for my
NSPersistenDocument-based app (Leopard-only, if that makes a
difference) in an external file (separate from the document Core Data
data store) and keeping an archived NDAlias reference to that file in
my document's data store. Ultimately, I would like the external data
file to end up in the same directory as the document (data store)
file. Since I may need to write data to the external data file before
the document is saved (this is a scientific data acquisition app and
losing data due to a crash is to be avoided if possible), I've taken
the following approach:

I would like to encapsulate the management of this external file in
the model-related classes since I will need the same functionality
during schema migration. Thus managing the external data file in my
NSPersistentDocument's subclass seems wrong. Thus, in the object
model's root object, I create the external file in
NSTemporaryDirectory() in the root objects awakeFromInsert method and
store the NDAlias referencing the data file. I would then like to move
the external data file to the same directory as the saved data store,
when a save occurs. I thought didSave would be the appropriate place
to do it, but it looks like during invocation of the didSave method,
the persistent store is still in a temporary directory (presumably
before being FSExchangeObjects'd to create an atomic save operation).
I plan to factor the logic in awakeFromInsert and didSave into class
methods so that they can be called during schema migration in a custom
entity policy's
createDestinationInstancesForSourceInstance:entityMapping:manager:error:
and endInstanceCreationForEntityMapping:manager:error: respectively.

So, my question: when during NSPersistentDocument save and during
schema migration can I be assured that my root object's
objectID.persistentStore.URL is the 'final' URL of the save (e.g.
where the user chose to save the file for document save)?

thanks,
Barry
_______________________________________________

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