0

I have a simple question:

How to show serial nos. or (row no. + 1) in a table column using cocoa bindings and array controller?

I have made an application using cocoa bindings and array controller, in which I am displaying names of certain persons in a table column. The class from which I am displaying is named as: Person. Now I want to show serial nos. in first column, such that list gets displayed like this :

1 / John

2 / Peter

It is very easy to do if I use data source method:

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex

I just need to return something like this :

return [NSString stringWithFormat:@"%d",rowIndex+1];

but I am not getting how to do this via cocoa binding and array controller.

Can anyone suggest me solution for it?

Thanks,

Miraaj

4

1 回答 1

1

您可以做到这一点的一种方法是实际混合使用绑定和具有相同表视图的数据源。继续为其余的表列连接绑定,但将要显示索引的列保留为未绑定。然后,只需为那一列正常实现表数据源。它应该只要求您提供 Amy 未绑定列的数据,其余的只使用绑定数据。

于 2010-08-15T17:08:40.310 回答