Question

I am trying to set text value of cell:

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    if ([[[tableColumn headerCell] stringValue] isEqualToString:@"Title"]) {
        NSLog(@"%@", [[array objectAtIndex:row] objectForKey:@"text"]);
        NSTextFieldCell *cell = [tableColumn dataCell];
        [cell setTitle:@"Cell"];
        return cell;
    }
}

But this doesn't works, there is no text in cell. How can I display text?

Was it helpful?

Solution

-(id)tableView:objectValueForTableColumn:row: should just return the string, not the cell.

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    if ([[[tableColumn headerCell] stringValue] isEqualToString:@"Title"]) {
        NSLog(@"%@", [[array objectAtIndex:row] objectForKey:@"text"]);
        return @"Cell";
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top