通过来源搜索表明没有隐藏的 CPTreeController,因此您可以编写自己的 CPTreeController 实现并将其贡献给社区,或者您可以为特定模型实现数据源协议,如下所示:
- (int)outlineView:(CPOutlineView)theOutlineView numberOfChildrenOfItem:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] count];
}
- (id)outlineView:(CPOutlineView)theOutlineView child:(int)theIndex ofItem:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] objectAtIndex:theIndex];
}
- (BOOL)outlineView:(CPOutlineView)theOutlineView isItemExpandable:(id)theItem
{
if (theItem == nil)
theItem = rootNode;
return [[theItem childNodes] count] > 0;
}
- (id)outlineView:(CPOutlineView)anOutlineView objectValueForTableColumn:(CPTableColumn)theColumn byItem:(id)theItem
{
return [[theItem representedObject] valueForKey:"name"];
}