Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BenCoffman

macrumors newbie
Original poster
Sep 5, 2009
9
0
I get this error
"NSImageCell's object value must be an NSImage"


When trying to bind my photo which is of type binary to my "view."

I'm not sure how else to do this, as the model does not give me the option of NSImage.
 
this class is not key value coding-compliant for the key managedObjectContext.

this class is not key value coding-compliant for the key managedObjectContext.

Furthering my above post.

I removed everything on my "Window" except for one column in a tableview.
everything runs fine until I add and array controller and bind it to the "File's Owner" class and set the "model key path" to "managedObjectContext."

Then it gives me the above error. I have one property in my entity and I have bound it to the table column. There is no way I have a typo. I must be missing something.
 
Your photo isn't of type "binary" unless you made a custom class called "binary" (which is likely a terrible idea if you did). Do you mean NSData? What is the class of the object storing your image?
 
It is not a class. I'm using the model maker thing. Of which it only gives you the ability to use native types for your properties in within your entities.

I've also noticed I don't have a myDocument.xib just a mainmenu.xib. I'm using the 10.6 library's with xCode 3.2

Would that cause an issue?
 
You'll probably need to write some additional non-coredata accessors to convert from your serialized binary blob in CoreData to an NSImage. Or only store the path to the image in CoreData and store the image itself in a separate file.
 
Solved

Here's how it goes.

The first mistake I made was not checking the "Create document-based application." This caused all the errors I posted about earlier. Once I checked this things went lots more smoothly. Note image:

xcode3.2.png




I was under the impression of not checking this because in Hillegass's book he states that for this exercise we will not be using NSDocument, but NSPersistentDocument instead. It turns out this still means you have to check "Create document-based application."

My next issue was with 10.6 and how it deals with binding binaries. Apparently you use "Value" now as opposed to "Data." This was a pretty easy fix as the error displayed made it quite clear. Again you have to go against what Hillegass specifically says in his book where he goes out of his way to state to not use "Value."

My third and last issue was accidentally binding to table cells as opposed to columns. This was a stupid mistake on my part, but I imagine I'm not the only one who has made this error nor will I will be the last. The error I got for this issue read like this.

Cannot create number from object () of class __NSArray0
 
How were you able to bind to Value? When I set the binding for Value I get an error in the app:

*** Canceling drag because exception 'NSInvalidArgumentException' (reason 'Unacceptable type of value for attribute: property = "photo"; desired type = NSData; given type = NSImage; value = <NSImage 0x100cab170 Size={225.6, 327.6} Reps=(
"NSBitmapImageRep 0x100cac630 Size={225.6, 327.6} ColorSpace=(not yet loaded) BPS=8 BPP=(not yet loaded) Pixels=564x819 Alpha=NO Planar=NO Format=(not yet loaded) CurrentBacking=nil (faulting) CGImageSource=0x100c9d000"
)>.') was raised during a dragging session
 
image view / image cell

@ BenCoffman,
In previous distributrions of Xcode, the Image View (not the Image Cell), needed to be the Data binding, not the Value binding (not sure which version of Xcode though).
I tried it using Xcode 3.2.2 and it still worked. However, I got a warning that the Data binding is deprecated. I solved it by using the Value binding, then selecting NSUnarchiveFromData in the Value Transformer dropdown box.

@Blakadher
I got that same error when trying to bind the value of the Image View, without selecting NSUnarchivingFromData as the Value Transformer.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.