0

For example the image below shows an NSOutlineView bound to a tree structure based on folders and items using an NSTreeController:

enter image description here

What I want is the Item objects to remain in the model, but not to be displayed as rows, i.e:

enter image description here

The NSOutlineView delegate protocol has a method that informs the delegate that an item is about to be displayed, but doesn't give the option not to display it.

Is there some way in which to subclass NSOutlineView to implement this (or some other method)?

Thanks.

Michael
  • 2,258
  • 1
  • 23
  • 31

1 Answers1

1

Presumably you're using NSTreeController which organizes your model objects according to the key path they use to identify their children.

If you want to filter anything out of the view, all you need to do is implement your child key path method to only return the children you want to display. (If you need to continue keeping track of the "real" children in your model, this may mean some extra bookkeeping to be able to return a separate list of children for display.)

rickster
  • 124,678
  • 26
  • 272
  • 326
  • Yep this is basically what I did in the end... My model has two arrays: children and childrenToDisplay which are then used by different TreeControllers. I don't really like the solution though tbh, it seems to me as if its breaking the MVC pattern - it's essentially storing information on what the view should display in the model! – Michael Jul 19 '12 at 08:12