A clean way to get an NSIndexPath object in an NSTreeController or NSOutlineView?

After looking at the documentation, I cannot find an easy way to get the index path of an object in the NSOutlineView or NSTreeController to which it is bound. As a result, I ended up writing really ugly code, trying to compose the index itself when I need to do something they need (like removing certain elements from a tree).

Is there a better way to do this than [[NSIndexPath indexPathWithIndex:<blah>] indexPathByAddingIndex: <blah>] ?

+4
source share
1 answer

You can easily build a path like this:

 NSUInteger indexes[4] = {2, 3, 1, 0}; NSIndexPath* path = [NSIndexPath indexPathWithIndexes:indexes length:4]; 

To get the pointer path to a specific model object, see my answer to this question .

+2
source

Source: https://habr.com/ru/post/1401928/


All Articles