2

So I admit to being a total noob to cocoa, so I offer a noob question. I'm probably just missing the dumb obvious somewhere but i just cant seem to get my table to populate data.

I'm following the table view playground example but everytime i try to mimic the Basic TableView Window the first row becomes the height of the number of rows i added (at least thats what it looks like. Here is my code:

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
    NSString *identifier = [tableColumn identifier];
    if ([identifier isEqualToString:@"filename"]) {
        // We pass us as the owner so we can setup target/actions into this main controller object
        NSTableCellView *cellView = [fileBrowserTable makeViewWithIdentifier:identifier owner:self];
        // Then setup properties on the cellView based on the column
        cellView.textField.stringValue = [fileList filenameAtIndex:row];
        cellView.imageView.objectValue = [[NSWorkspace sharedWorkspace] iconForFile:[fileList fullPathAtIndex:row]];
        return cellView;
    }
    else if ([identifier isEqualToString:@"path"]) {
        NSTextField *textField = [fileBrowserTable makeViewWithIdentifier:identifier owner:self];
        textField.objectValue = [fileList pathAtIndex:row];
        return textField;
    }
    else if ([identifier isEqualToString:@"preview"]) {
        NSTextField *textField = [fileBrowserTable makeViewWithIdentifier:identifier owner:self];
        textField.objectValue = [fileList previewAtIndex:row];
        return textField;
    }
    return nil;
}

I think its worth mentioning that when using a the old school text field cell, I have no problems displaying data (of course the above code is different in that case) so im positive sure its not a problem with my data structure that holds the values. I have also set the correct delegate and data source

The cell using the 'filename' identifier uses the 'image and text table view cell' while the others use just a 'text table cell view'. Neither of them work so i'm guessing something is wrong with how I set my table up. But when comparing my table with that of the example, it's just a spitting reflection (minus identifiers file names).

One thing that I notice that I can't quite figure out is that the example says:

The NSTableView has two reuse identifier assocations: "MainCell" and "SizeCell" are both associated with the nib ATBasicTableViewCells.xib

I don't really understand this statement. However that being said, the example doesn't contain any ATBasicTableViewCells.xib nor does it have any associations with it (code or ib) that I can find.

Jacob
  • 1,052
  • 8
  • 10

1 Answers1

0

Have you tried to set the rowSizeStyle of the NSTableView to NSTableViewRowSizeStyleCustom? [UPDATE] Re-reading your question, it's not clear for me what your problem is. The solution I have given is related to problems with the size of each cell which is not taken into account unless the rowSizeStyle is set to custom.

FKDev
  • 2,266
  • 1
  • 20
  • 23