Displaying image and core data
Displaying image and core data
- Subject: Displaying image and core data
- From: Kubernan from 10191 Technologies <email@hidden>
- Date: Wed, 16 Nov 2005 21:24:16 +0100
Hello,
I have a core data entity called "Person" with a binary attribute
("originalPicture") for storing picture of a person.
In my GUI i have an NSImageView binds to orginalPicture for
displaying the person's picture.
In my code, when the user choose a picture from an open file panel i
thought i could do that :
anImage = [[NSImage alloc] initWithContentsOfFile:[filesToOpen
objectAtIndex:0]];
[personalityController setValue:anImage
forKeyPath:@"selection.originalPicture"];
Of course, it doesn't work : the console says :
Unacceptable type of value for attribute: property =
"originalPicture"; desired type = NSData; given type = NSImage; value
= NSImage 0x34a000 Size={640, 480} Reps=(
NSBitmapImageRep 0x340bb0 Size={640, 480}
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=24 Pixels=640x480
Alpha=NO Planar=NO Format=0
).
If i do :
[personalityController setValue:[NSData dataWithContentsOfFile:
[filesToOpen objectAtIndex:0]] forKeyPath:@"selection.originalPicture"];
I have this message :
NSImageCell's object value must be an NSImage.
So what should i do for storing a picture with core data and
displaying it in my GUI ?
I read the apple document about binding and viewing image but i don't
know if it's the good
solution to my problem.
Thanks,
K
_______________________________________________
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