Say I have a NSTableView (for example, a
) and a NSOutlineView (for example, b
).
In the datasource of a
I'm trying to get the parent item of all the selected items of b
. In the row no. rowIndex
of a
I would like to have the rowIndex
th selected item of b
and I would like to concatenate this string to the name of the parent of this item. For example, a
:
- 1 and 1.1
- 2
And b
:
- 1
- 1.1 (selected)
- 2 (selected)
- 3
This is - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
of a
.
NSUInteger index = [[outlineView selectedRowIndexes] firstIndex];
for (NSUInteger i = 0, target = rowIndex; i < target; i++)
index = [[outlineView selectedRowIndexes] indexGreaterThanIndex:index];
NSLog(@"%@", [outlineView [outlineView itemAtRow:index]]);
if([outlineView parentForItem:[outlineView itemAtRow:index]] != NULL) {
return [NSString stringWithFormat:@"%@ %@", [outlineView parentForItem:[outlineView itemAtRow:index]], [outlineView itemAtRow:index]];
} else {
return [outlineView itemAtRow:index];
}
return NULL;
The problem is that when I expand an item [outlineView parentForItem:[outlineView itemAtRow:index]]
returns always the last expanded item.
I am trying to have a list of selected items and their parents. When I expand an item, all items change their parent to last expanded item
.
Am I doing something wrong?
Thank you in advance.