Reputation: 2639
I have an NSOutlineView as a sourcelist, like Mail.app. Its content is bound to an NSTreeController, which manages an array of my model objects. I've implemented drag-and-drop on the sourcelist and this is working perfectly.
Now I'd like to save the new ordering when the user finishes a drag-and-drop action in the sidebar. However, I can't find anything describing how this would usually be done.
The best I can come up with is:
treeIndex
property to my model class, to store the model's position in the sourcelisttreeIndex
propertyThe problem is, I can't find how to retrieve the arranged objects from the NSTreeController. I can't get treeController.arrangedObjects
to give me anything useful!
Searching through Github repos I've seen numerous uses of treeController.arrangedObjects.childNodes!!
but that just throws a Value of type 'Any' has no member 'children'
syntax error for me.
The following pseudo-code might help describe what I am trying to do after each drop action:
let parentNode = treeController.nodeAtIndex([0, 0])
for childNode in parentNode.children {
(childNode.representedObject as SidebarItem).indexPosition = childNode.index
}
Upvotes: 0
Views: 129