Filtering a NSOutlineView/NSTreeController
-
19-09-2019 - |
Question
How would I use a search box to filter a NSOutlineView/NSTreeController? I know it would have something to do with bindings and a predicate. But not specificaly how to. Could someone take me through the steps of filtering an NSOutlineView/NSTreeController?
Solution
I don't think you can. NSArrayController allows you to give it a filter predicate; NSTreeController doesn't. I suggest you file a bug.
OTHER TIPS
As of macOS 10.11, NSTableView
(and therefore the subclass NSOutlineView
) has new hideRows
& unhideRows
methods that simplify the task to filtering out rows. There's still no automatic support for filtering out items in NSTreeController
(which is not a subclass of NSArrayController
, and thus does not inherit its filter
predicate), but it at least does a lot of the heavy lifting of allowing you to keep the whole model in the controller while only displaying only a subset of it.