I have multilevel hierarchy in my outlineview. I am able to get the selected item and it's parent item using below code.
func outlineViewSelectionDidChange(_ notification: Notification) {
guard let outlineView = notification.object as? NSOutlineView else {return}
if let item = outlineView.item(atRow: outlineView.selectedRow) as? CubeData{
// Getting the parent item
if let parentItem = outlineView.parent(forItem: item) as? CubeData{
print("Parent Item value:", parentItem.node)
}
print("Selected Item value:", item.node)
}
}
But not able to get all the grand parent items.
For example A->B->C->D is my hierarchy and whenever I am selecting "D" I am able to get "C" and "D". I want all the parent items. Any help?