Re: CoreData Mysterious Conditional Data Loss
Re: CoreData Mysterious Conditional Data Loss
- Subject: Re: CoreData Mysterious Conditional Data Loss
- From: "I. Savant" <email@hidden>
- Date: Thu, 24 Sep 2009 10:09:06 -0400
On Sep 24, 2009, at 9:59 AM, Milen Dzhumerov wrote:
You got it right first time, many thanks. The images were created
using NSImage's initByReferencingFile: which I presume only
references the image file. That's what I thought at first (that
CoreData stored the path to the image within the bundle so when the
bundle was moved, it couldn't find the file) but then I looked at
the raw data stored in the XML file (which was base64 encoded) and
saw the actual PNG data with no filesystem paths. It seems that I
there's more magic going on behind the scenes. In any case, thanks
for the help.
I don't think this is Core Data magic so much as NSImageView's
caching magic. I would expect an archived copy of this image to be
stored only with its file reference, not with its data (while still
attempting to reference the file when it's recreated). I would call
this a bug if a careful review of the documentation doesn't reveal
something you missed. Since I haven't used -initByReferencingFile: or
tried to archive an image created with it, I haven't read the
documentation regarding this approach, so I leave that to you.
In any case, you need to decide if you want to store the image
itself (ie, its data) or just a reference to it.
If you only need a file reference, you can use an FSRef (lots of
convenient Cocoa wrappers exist on the web) for anything before Snow
Leopard or use Snow Leopard's latest FSRef-loving NSURL goodness.
If you need the image data itself, try leaving your attribute as
Transformable and creating the image with –initWithContentsOfFile: or –
initWithContentsOfURL: and storing that. I think that'll work for you.
Alternatively, you could store the image's data as an NSData attribute.
--
I.S.
_______________________________________________
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