I\'m trying to implement the new view-based OutlineView as a source list in my Mac app. I can\'t get values to display, though, so I made a small test app from the Core Data app
As Boaz noted above, you need to implement the Delegate method to return a view.
Quite a mystery considering I could not find that method in the Docs.
Regarding the type of the (id)item
parameter, it's a NSTreeControllerTreeNode
which is an undocumented subclass of NSTreeNode
. If you cast it you can get the cell's object, and return different view based what kind of object is, or whatever attributes of that object determine the cell view type:
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
NSTableCellView *view = nil;
NSTreeNode *node = item;
if ([node.representedObject isKindOfClass:[Group class]]) {
view = [outlineView makeViewWithIdentifier:@"HeaderCell" owner:self];
} else {
view = [outlineView makeViewWithIdentifier:@"DataCell" owner:self];
}
return view;
}