Persistent Stores and Packages ...
Persistent Stores and Packages ...
- Subject: Persistent Stores and Packages ...
- From: SA Dev <email@hidden>
- Date: Mon, 23 May 2005 12:42:02 -0400
List:
I have a Core Data document-based application I'm working on. For
various reasons, I want it to save its data in a package format. I'm
doing this because there are a lot of large, supporting binary files
that belong to the type of project this app will manage. I also want
my users to be able to extract the data files (including the project
data itself in XML format, thanks to Core Data) should my app somehow
suddenly disappear from the face of the earth for some reason.
I have two problems at the moment that seem very scary and appear
to have many sharp teeth ...
- The first is how to get my XML store (which is saving and opening
just fine right out of the box) to be saved to and read from a
package. What do I fudge with? Subclass a context, a persistent
store, or will NSPersistentDocument do everything I need it to if I
only override the correct methods? I'm aware I have to check the
"Package" checkbox in my document types (I have a document with my
chosen extension and a unique UTI, XML store type). What reference
material can help me with this? Has anyone tried this yet?
- The second problem may be answered by the first problem's solution.
I need to know how my NSManagedObject subclasses can ask their
document for the package path (so, say, a "StoredImage" object can
write itself to the package's Stored Images subfolder on -willSave
and load/cache it again when its imageData is asked for. Or is this
not the best way to do it? Let me elaborate ...
I'm using the delayed set accessor approach outlined in the Core
Data Programming Guide in my StoredImage object. When an image well's
data object is set, the data is stored in the object's imageData
property. When the context is saved, the file is written to the
package. When the imageData property is accessed, the file is read
and cached, then returned. The file name used in the package would be
derived from its objectID like "/Users/me/My Project.myproj/Stored
Images/8D93298F-07B8-421E-AAB0-87454A41F2B0". Should the
NSManagedObject "StoredImage" be responsible for finding its package
path and writing the file in this way?
Thanks in advance for any help or guidance in the right direction.
I hope some answers will come back that allow me to de-fang this
intimidating Tiger challenge.
-SADev
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden