Re: Saving Images with Core Data (i.e., JPEG, TIFF, etc.)
Re: Saving Images with Core Data (i.e., JPEG, TIFF, etc.)
- Subject: Re: Saving Images with Core Data (i.e., JPEG, TIFF, etc.)
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 29 Apr 2005 11:37:48 -0700
On Apr 29, 2005, at 11:24 AM, Marc Blatt wrote:
This may be something obvious that I am missing, but how do you
save an image file (let's say jpeg) with Core Data into the object
graph. The obvious way is storing by reference with an attribute
that saves the string name. However, how would you actually store
the image within the binary or sql file? Still trying to grasp Core
Data's power...
It's not clear what you mean by "save an image file" in the context
of your suggestion of "storing by reference with an attribute that
saves the string name".
I assume you'll actually be storing the the image data as an NSData
object, in which case you can specify a data attribute of an entity
that holds the image data. If not, you can specify a string
attribute that identifies a file location (obviously this is a little
more fragile if files may be moved independently of your application).
If you want to store the image data in your file, first you should
not use the XML store (as you already imply). Second, I would
suggest that you actually use the SQLite store and if an entity
conceptually has a large data blob as an attribute that you actually
specify a separate entity for that attribute. For example, if a
Person entity should have a 'photo' attribute, then create a Photo
entity with just a single attribute -- the data -- and if you care a
relationship back to the Person (typically modeling relationships in
both directions is a Good Thing). Then create a relationship from
the Person to the Photo entity. This will mean that photo data is
only loaded from the persistent store if you actually use it.
mmalc
_______________________________________________
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