【发布时间】:2013-05-31 15:39:14
【问题描述】:
我有两个基于单元格的表格视图(项目和类别)。我正在尝试为每个获取正确的行索引,以便可以使用它们的数组。
到目前为止我的代码是这样的:
- (id) tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row {
//NSLog(@"%s", __FUNCTION__);
if (tableView.tag == 0) {
currentItem = [itemMutableArray objectAtIndex:row];
NSString *itemTitle1 = [currentItem valueForKey:@"title"];
return itemTitle1;
} else {
currentCategory = [categoryMutableArray objectAtIndex:row];
NSString *catName = [currentCategory valueForKey:@"name"];
NSLog (@"currentCategory is %@", catName);
return catName;
}
}
但是对于每个表,这会返回类似:
currentCategory is Cat One
currentCategory is Cat Three
currentCategory is Cat One
currentCategory is Cat Three
currentCategory is Cat One
currentCategory is Cat Three
currentCategory is Cat Two
currentCategory is Cat One
currentCategory is Cat Three
...
是我使用了错误的方法,还是什么?谢谢。
【问题讨论】:
-
我希望能够识别每个表的具体行。
-
我们需要知道您的数组的内容以及日志应该说什么。