Reputation: 38411
According to Apple's documentation, NSOutlineView
requires each item in the view to be unique, however, what if this doesn't actually fit the business requirement? In particular, how do you display something like this
Item A
-> Item B
-> Item E
-> Item C
Item D
-> Item B
-> Item E
-> Item F
Note how Item B, as well as its children, appear in the tree multiple times. Of course, the application does checks to make sure no circular loop can happen so the tree is finite.
Would subclassing the NSOutlineView
help? Or would a completely new view class need to be created?
Upvotes: 0
Views: 226
Reputation: 96373
You could use NSIndexPath objects as the items in the outline view. For example, index path (0, 0) would refer to Item B of Item A, while index path (1, 0) would refer to Item B of Item D.
You won't be able to use Bindings; you'll need to implement a data source.
Your data source methods will need to get the relevant real model object from your model using the index path. I recommend making a method that does that and using that method from all of the data source methods.
Also, you'll need to correctly handle deleting objects: If you delete an object in the middle of the model array, you have to delete the index path at the end, not the one in the middle, and tell the view to reload all the items (index paths) in between.
Upvotes: 1