Resolved NSImage in NSTableView column

Discussion in 'Mac Programming' started by larswik, Dec 2, 2011.

  1. larswik, Dec 2, 2011
    Last edited: Dec 3, 2011

    larswik macrumors 68000

    Sep 8, 2006
    I have an NSTableView with about 6 columns. All the columns are text but the first one I want as an NSImage. Reading through the docs it seems that a cell can be text or image initWithText or initWithImage. So in a delegate method for the tableview I had it look at the identifier and if it was the image it would make an image Cell and return that instead of the default which seems to be the text Cell. The end result is a blank column?
    -(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
        Item *newItem = [tableViewItemList objectAtIndex:row];
        NSString *identifier = [tableColumn identifier];
        if ([identifier isEqualToString:@"image"]) {
            NSCell *imageCell = [[NSCell alloc] initImageCell:newItem.image];
            return imageCell;
            return [newItem valueForKey:identifier];
  2. larswik thread starter macrumors 68000

    Sep 8, 2006
    I got it working. I dragged in an Image Cell and dropped in on my first column and now the images load just fine.

    Could someone tell me how to mark this thread solved, I can't seem to find it?
  3. kainjow Moderator emeritus


    Jun 15, 2000
    Here you go.

Share This Page