emreoktem
emreoktem

Reputation: 2547

Filtering children of NSOutlineView with NSTreeController

I am developing a Mac app which uses Core data. I am using NSOutlineView and NSTreeController to bind data on view.

You can assume the structure of my data as

I am applying a fetchPredicate to my NSTreeController to filter the data successfully. On the other hand, the fetchPredicate is applied only to the first level of the data (to parent Items).

I need a method which I can apply a fetchPredicate also to the child items. For example if my criteria matches to Child Item 1 and Child Item 4 the result should be

Any help will be appreciated.

Upvotes: 0

Views: 821

Answers (1)

Willeke
Willeke

Reputation: 15623

You're applying a fetch predicate. NSTreeController doesn't support a filter predicate. NSTreeController uses the fetch predicate to fetch the top level objects and uses the children relationship to get the children. The children aren't fetched and the fetch predicate is not used to get the children.

Solution 1: implement a calculated property filteredChildren, like in this question: Filtering A Tree Controller and mentioned in this unrelated answer: Is it possible to bind an NSTreeController to an NSOutlineViewDataSource?

Solution 2: use a data source instead of bindings, also mentioned in the above answer.

Upvotes: 0

Related Questions