Pregunta

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?

¿Fue útil?

Solución

-(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";
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top