NSImageCell's object value must be an NSImage -- Hillegass

Discussion in 'Mac Programming' started by BenCoffman, Sep 26, 2009.

  1. BenCoffman macrumors newbie

    Joined:
    Sep 5, 2009
    #1
    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.
     
  2. BenCoffman thread starter macrumors newbie

    Joined:
    Sep 5, 2009
    #2
    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.
     
  3. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #3
    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?
     
  4. BenCoffman thread starter macrumors newbie

    Joined:
    Sep 5, 2009
    #4
    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?
     
  5. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #5
    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.
     
  6. BenCoffman thread starter macrumors newbie

    Joined:
    Sep 5, 2009
    #6
    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:

    [​IMG]



    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
     
  7. Blakadher macrumors newbie

    Joined:
    Sep 10, 2009
    #7
    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
     
  8. Fnordis Cord, Mar 29, 2011
    Last edited: Mar 29, 2011

    Fnordis Cord macrumors newbie

    Fnordis Cord

    Joined:
    Dec 9, 2009
    Location:
    Belgium
    #8
    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.
     

Share This Page