Reputation: 12436
OK so I've got a sidebar built using an NSOutlineView. I currently have two sections in the sidebar which can be expanded/contracted. I would like to be able to determine which section the selected row belongs to.
- Section 1
-- Item 1
-- Item 2
-- Item 3
- Section 2
-- Item 4
-- Item 5
The problem is that the selectedRow value changes depending on whether sections are expanded or not. Is there no easy way to determine which section the row belongs to without manually keeping track of expansion/contraction and the number of items in each section?
Upvotes: 1
Views: 531
Reputation: 4920
Try this:
//returns id of section, where currentRow is a selectedRow
id section = [yourNSOutlineView parentForItem:[yourNSOutlineView itemAtRow:selectedRow]];
Upvotes: 2
Reputation: 26365
You could call [NSOutlineView itemAtRow:] with the index of the selected row.
Upvotes: 0