Reputation: 418
I'm using an NSTreeController
set in entity mode, to manage a hierarchy of folders (a core data entity I call Folder
). The "Children" key path is set to an NSArray
readwrite property of Folder
, which I call subfoldersArray
. (I use NSArray
because NSOrderedSet
doesn't work with a tree controller).
When the user moves a folder to another folder (via an NSOutlineView
) or at a different position of the same parent folder, the app calls moveNode:toIndexPath:
on the tree controller. I use this method as it preserves the selection (while changing the underlying model tends to deselect the selected folder, even though the controller has preserveSelection
set to YES
.
Problem: every Folder
instance that is moved by moveNode:toIndexPath:
is placed at the end of the subfoldersArray
, regardless of the index path specified.
This happens only when the NSTreeController
controls an NSManagedObject
subclass (in either class or entity mode).
The exact same moveNode:toIndexPath:
instruction on the same NSTreeController
controlling an equivalent NSObject
subclass (with an identical subfoldersArray
property) works as expected.
I'd like a solution that doesn't involve setting the underlying model myself, as this tends to deselect the selected folder (which may not be the one that is moved).
Upvotes: 1
Views: 61