João Colaço
João Colaço

Reputation: 1301

Expand all the items of an NSOutlineView to a level

How can I, on setup, expand all items of an NSOutlineVIew to a determined level? After this the user it's free to expando or collapse all the nodes of the tree.

The data comes from a NSTreeController bound to the view.

Upvotes: 1

Views: 768

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90561

This should do it:

for (NSInteger i = 0; i < outlineView.numberOfRows; i++)
{
    if ([outlineView levelForRow:i] < depthLimit)
        [outlineView expandItem:[outlineView itemAtRow:i]];
}

Upvotes: 2

Related Questions