1

Scenario:

  • NSOutlineView with Cocoa bindings on NSTreeController. NSOutlineview selection is bound to treeController.selectionIndexPaths
  • Add 3 items in the model
  • Set selection of these new items programatically on NSTreeController
    • treeController.setSelectionIndexPaths([IndexPath(indexes: [4,0]),IndexPath(indexes: [0,0]),IndexPath(indexes: [0,1])]) // NOK
    • treeController.setSelectionIndexPaths([IndexPath(indexes: [0,0]),IndexPath(indexes: [4,0]),IndexPath(indexes: [0,1])]) // OK
    • treeController.setSelectionIndexPaths([IndexPath(indexes: [0,0]),IndexPath(indexes: [0,1]),IndexPath(indexes: [4,0])]) // OK

In the first case, the NSOutlineViewdoes not select the right item. The [4,0] item is not selected, instead the [3,0] is selected. The selection is actually correct in the treeController because when I delete the items in the selection of the treeController, the right items are removed.

This is the OutlineView not properly reflecting the TreeController's selection in a specific case.

This looks like a bug to me, but I'm asking your expert advice to know if I did something wrong here.

Thanks!

vomi
  • 993
  • 8
  • 18
  • I found that [scheduling the selection update on the main queue](https://stackoverflow.com/questions/23773827/how-can-i-determine-if-apple-methods-are-asynchronous) made some of these head-scratchers disappear. The "Add 3 items" part of your code might look synchronous and not be. – stevesliva Dec 05 '19 at 15:47

0 Answers0