I'd like to expand every node in my -awakeFromNib().
As of Mac OS X 10.5, [outlineView expandItem:nil expandChildren:YES]
.
In previous versions of Mac OS X, you'll need to iterate from 0 to the number of rows, getting the item for each row using [outlineView itemAtRow:row]
, and storing those items into an array, then iterate the array and pass each item to the expandItem:expandChildren:
method. (You can't mix the two loops because expanding an item and all its descendants will change the row indexes of its subsequent siblings; therefore, you must collect all the top-level items first, then expand them once you have all of them.)
I'd also like to programatically select the first child of the first node at the same time.
Immediately after the above, it'll be row 1.
An outline view is a kind of table view, so you'll use one of NSTableView's methods: [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO]
.