开发者

How do I only update specific columns in an NSTableView

I have an NSTableView, with two columns. Whenever I add data to the table, both columns display the same data. How do I开发者_StackOverflow only update a specific column?

I'm doing Mac Dev btw.

This is the code I'm using:

- (id)tableView:(NSTableView *)streamView objectValueForTableColumn:(NSTableColumn     *)messageCol row:(int)row
{
return [[stream respond] objectAtIndex:row];
}

Thanks.


Check which column you're being asked to fill in in your implementation of tableView:objectValueForTableColumn:row:. That's why it passes you the column! Quick example, since you seem to be ignoring the "check what column you're being asked to fill in" part:

- (id)tableView:(NSTableView *)tableView
       objectValueForTableColumn:(NSTableColumn *)column 
                             row:(int)row
{
    if ([[column identifier] isEqualToString:@"A"])
        return [columnArrayA objectAtIndex:row];

    if ([[column identifier] isEqualToString:@"B"])
        return [columnArrayB objectAtIndex:row];

    return nil;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜