Search code examples
xcodensoutlineview

How can i disable sorting in outline view in xcode 4?


I'm using Nsoutline view with core data and array controller , how can i disable sorting array ?


Solution

  • An array controller or a tree controller? Usually, you'd use an array controller with a table view and a tree controller with an outline view.

    Bind the content and selectionIndexPaths bindings of the outline view itself to the tree controller using key paths "arrangedObjects" and "selectionIndexPaths", respectively. Don't bind the outline view's sortDescriptors binding to anything.

    Normally you don't bind the outline view's bindings directly. In that case, the outline view's content, selectionIndexPaths, and sortDescriptors bindings are automatically bound to the tree controller to match the value binding of the columns. When you bind some of those yourself, it prevents this automatic binding. Since you've not bound sortDescriptors and you've prevented the automatic binding, sorting is disabled.