Re: Core Data: Unable to store a NSData object into an entity's binary property.
Re: Core Data: Unable to store a NSData object into an entity's binary property.
- Subject: Re: Core Data: Unable to store a NSData object into an entity's binary property.
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 8 Jan 2006 13:56:26 -0800
On Jan 8, 2006, at 12:03 PM, Frederick C. Lee wrote:
- (void)setImage:(NSImage *)inImage {
[inImage retain];
[image release];
image = inImage;
}
- (NSImage *)image {
return image;
}
I assume that image is a transient property of GVManagedObject?
It's not clear why these accessors don't have the KVO access and
change notification method invocations?
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdNSAttributes.html>
[map setValue:[NSString stringWithFormat:@"%@ Map",inRegion]
forKey:@"name"];
NSData *myData = [NSData dataWithContentsOfFile:
@"/Users/Ric/Library/Application Support/Eccron/Maps/tiff/
Europe1.tif"];
if (myData)
[map setValue:myData forKey:@"imageData"];
[...]
3) Last mininute check of imageData (NSData binary):
(gdb) po [managedObjectContext insertedObjects]
<NSCFSet: 0x4819370> (<GVManagedObject: 0x4818c60> (entity: Map;
id: 0x4818ca0 <x-coredata:///Map/t4741E729-
E177-4428-92EB-8C1558597EA4> ; data: {
city = nil;
country = nil;
image = nil;
imageData = <4d4d002a 00000008 001400fe 00040000 00010000
00000100 00030000 000102a3 00000101 00030000 00010203 00000102 0003>;
Note, image == nil.
Then:
- (void)willSave {
NSImage *tmpImage = [self primitiveValueForKey:@"image"];
[self setPrimitiveValue:[tmpImage TIFFRepresentation]
forKey:@"imageData"];
[super willSave];
}
you set imageData to nil...
The Core Recipes example (<http://developer.apple.com/samplecode/
CoreRecipes/CoreRecipes.html>) illustrates how to store images
directly, and in particular uses a relationship to a "media" entity
so that large data BLOBs are not loaded unnecessarily. It might be
easier to start by adapting that.
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