Question

I have a table that gets it's values from core data and is added via cocoa bindings. The values that are printing out in the table are folder names.I would like to have a NSFolder printed out to the left of each folder name. I started off with a simple one column table to make sure my cocoa bindings work, and they do:

enter image description here

After that I tried addin a second column, then I added an image cell to that new column, rearranged the columns, and set image cell's image to NSFolder:

enter image description here

When I change the image cell's image to NSFolder, nothing happened, not even in the interface builder. The icon remained an Xcode icon. And when I ran the build command, there was just a blank space to the left of the folder name.

From there I tried going back to one column and adding an image & Text Table Cell View but I couldn't even get the cocoa bindings to work with that.

So how do I just print display a static NSFolder on the left hand side of each of the folder's names?

Edit: This is what I'm trying to achieve:

enter image description here

Edit #2

I tried implementing the NSTableViewDelegate and adding the following method:

- (NSView *)tableView:(NSTableView *)tableView
   viewForTableColumn:(NSTableColumn *)tableColumn
                  row:(NSInteger)row
{
    NSTableCellView *cellView = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
    if ([tableColumn.identifier isEqualToString:@"FolderImageColumn"]) {
        cellView.imageView.image = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)];
        return cellView;
    }
    return cellView;
}

But now I'm getting completely blank rows. They're clickable and they load the data on the right hand side, but they're completely blank.

enter image description here

Était-ce utile?

La solution

If you implement the delegate methods you can interact with the cell/view when it is displayed and force the folder or based on content/type any other image.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top