Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann
To get all the nodes in the tree I do a depth-first search (10.5 only). Add the first method in an NSTreeNode category and the second to a category on NSTreeController. // NSTreeNode_Extensions - (NSArray *)descendants; { NSMutableArray *array = [NSMutableArray array]; for

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread Rick Mann
Jonathan, thank you for the excellent example on working with the containers. That will certainly be useful. On May 31, 2008, at 02:57:36, Jonathan Dann wrote: If you're using Core Data, can't you fetch all your managed objects and determine the one with the max vaule? Well, I would

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread I. Savant
Well, I would have thought so, but I don't know enough about CoreData to actually get at the objects without the tree controller. I would've thought I could do that just off the tree controller, using @max, too. 1 - Create a fetch request for your desired entity. 2 - Create a sort

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread Rick Mann
On May 31, 2008, at 12:05:58, I. Savant wrote: 1 - Create a fetch request for your desired entity. 2 - Create a sort descriptor for the key whose max value you're interested in. 3 - Set the fetch request's sort descriptor to the above. 4 - Create any predicates needed for filtration (ie,

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann
On 31 May 2008, at 19:47, Rick Mann wrote: Jonathan, thank you for the excellent example on working with the containers. That will certainly be useful. You're welcome, but I apologise, I forgot the -rootNodes method that one of the tree controller methods I sent you calls! This method

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread I. Savant
Wow, really? No way to just get at all the items in the tree controller with some key path, then use @max? It seems that this would be possible with an NSArray: In addition to Jonathan's comments, to be fair, you did ask, ... I don't know enough about CoreData to actually get at the

Re: Finding the largest value in an NSTreeController?

2008-05-31 Thread Jonathan Dann
On 31 May 2008, at 21:43, Rick Mann wrote: Can category methods act as KVC properties? Yep, the -flattenedObjects method I gave you asks the array of tree nodes valueForKey:@descendants. -descendants was the NSTreeNode method I posted. Jon smime.p7s Description: S/MIME