• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Displaying image and core data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying image and core data


  • Subject: Re: Displaying image and core data
  • From: Justin Burns <email@hidden>
  • Date: Wed, 16 Nov 2005 15:04:48 -0800

Have you tried setting NSUnarchiveFromData as your Value Transformer in the Data bindings pane?

It seems like this would do exactly what you need, assuming you generated your original data with something like:
[personalityController setValue:[NSArchiver archivedDataWithRootObject:anImage]; forKeyPath:@"selection.originalPicture"]


-justinb


On Nov 16, 2005, at 12:24 PM, Kubernan from 10191 Technologies wrote:

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:
40shipwreckbeads.com


This email sent to email@hidden

_______________________________________________ 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
  • Follow-Ups:
    • Re: Displaying image and core data
      • From: Scott Stevenson <email@hidden>
    • Re: Displaying image and core data
      • From: Justin Burns <email@hidden>
References: 
 >Displaying image and core data (From: Kubernan from 10191 Technologies <email@hidden>)

  • Prev by Date: Re: How to get Tool Tip color ? -- Solved
  • Next by Date: Re: How to get Tool Tip color ? -- Solved
  • Previous by thread: Re: Displaying image and core data
  • Next by thread: Re: Displaying image and core data
  • Index(es):
    • Date
    • Thread