views:

28

answers:

1

I would like a NSCell in an OutlineView to display the number of the children the row it's has. Here's what I mean:

alt text What's on the right, but for all rows.

How would I go about finding out, first, which row the NSCell is and then from there getting the number of children that row has.

+1  A: 

PXSourceList does this.

edit re: the comment about displaying the number of children in the badge

If you use the excellent PXSourceList, then you'll simply implement a single delegate method:

- (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item;

Most likely, you'll implement this as:

- (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item {
  return [self sourceList:aSourceList numberOfChildrenOfItem:item];
}
Dave DeLong
PXSourceList seems to only deal with the badge itself, not finding the number of children it's row has (bearing in mind I'm using Core Data).
Joshua
@Joshua the cell shouldn't care about "children". That'd be coupling the View to your Model, which isn't recommended. Instead, the View should simply have a number to draw there, but shouldn't care *where that number comes from*
Dave DeLong
Okay, I understand what you mean about keeping them separate. But how would I go about **displaying the number of children** the badges row has **inside the badge**?
Joshua
@Joshua edited answer
Dave DeLong
Thanks, how much more complicated would it be if I didn't use PXSourceList and just used a Text Cell in the column as the badge?
Joshua
@Joshua you'd have to create a custom NSCell subclass to do the drawing yourself.
Dave DeLong