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?

Était-ce utile?

La 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";
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top