Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 800639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:19:13+00:00 2026-05-14T23:19:13+00:00

In my code I am storing an image into my Core Data model (works

  • 0

In my code I am storing an image into my Core Data model (works fine). If I set up my view to have an NSImageView and bind its Data to Controller Key: selection and modelKeyPath: myImagePath, it works. It will show each image for the selected row.

I then create a new column in my NSTableView and drag an image cell onto the column. However, I cannot get my Core Data bindings to have the image show up in the cell. I have tried binding both value and data, but no luck.

Since I am sure the image is stored properly, what am I doing wrong in my binding to prevent the image from showing up in the table cell?

Thanks so much.

(My background: new Cocoa developer who has recently gone through the entire Hillegass book.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:19:14+00:00Added an answer on May 14, 2026 at 11:19 pm

    I’m not sure what is happening to cause your problem but there’s an easy way to find out. Hook up an NSValueTransformer to the binding. Then in that transformer you can log stuff to find out if you’re passing a nil value, or you can transform your data value into an NSImage and pass that back… basically you can do whatever you want in the transformer class. Here’s one I use on image data in a core-data model.

    @interface DataToImageTransformer : NSValueTransformer {
    
    }
    
    @end
    
    
    @implementation DataToImageTransformer
    
    + (Class)transformedValueClass {
        return [NSImage class];
    } // the class of the return value from transformedValue:
    
    + (BOOL)allowsReverseTransformation {
        return YES;
    } // if YES then must also have reverseTransformedValue:
    
    - (id)transformedValue:(id)value {
        if (value == nil || [value length] < 1) return nil;
        NSImage* i = nil;
        if ([value isKindOfClass:[NSData class]]) {
            i = [NSKeyedUnarchiver unarchiveObjectWithData:value];
        }
        return i;
    }
    
    - (id)reverseTransformedValue:(id)value {
        if (value == nil) return nil;
        NSData* d = nil;
        if ([value isKindOfClass:[NSImage class]]) {
            d = [NSKeyedArchiver archivedDataWithRootObject:value];
        }
        return d;
    }
    
    @end
    

    In AppController class you initialize the transformer:

    + (void)initialize {
        DataToImageTransformer *transformer = [[DataToImageTransformer alloc] init];
        [NSValueTransformer setValueTransformer:transformer forName:@"DataToImageTransformer"];
        [transformer release];
    }
    

    Then in Interface Builder you put “DataToImageTransformer” in for the binding. Now you have control over the binding and can do as I explained earlier in the transformer class. Note that I’m using NSKeyedArchiver to convert an NSImage to data and back again but you can use tiffRepresentation or any other method you want in its place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an image upload handler (.ASHX). I am storing image meta data in
Right now I have a Rails 3 model for storing profile data. One of
I have a table with column for storing product code. | product_id | Product-name
I am trying to get the size of PNG image (Without storing into file).
Can someone tell me the code to convert image into byte array and that
I have added an image into a MySql database. And I am trying to
I have issue with printing session saved image data back in Drupal CMS. The
I am storing the image and other details of visitor into table tbl_visitor. The
this code will not pass the query string to default3.aspx on Image Button ..
I've read the several discussions about storing code snippets but I did't find the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.