FROM : Jonathan Dann
DATE : Sat May 31 22:26:02 2008
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
returns the top-level objects in the tree (NSTreeController.h assures
me that -arrangedObjects responds to -childNodes, this differs from
what the docs say).
// NSTreeController_Extensions
- (NSArray *)rootNodes;
{
return [[self arrangedObjects] childNodes];
}
now it'll work!.
> 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, whatever you
>> may or may not have used in the tree controller).
>> 5 - Set the fetch request's predicate to the above if any.
>> 6 - Execute the fetch request and get the last (or first) object of
>> the results (checking for errors, minding the set-versus-array
>> gotchas, etc.).
>
>
> Wow, really? No way to just get at all the items in the tree
> controller with some key path, then use @max?
Think of this this way, only the tree controller knows which objects
it has in it. The context and the model objects are ignorant of
this. The entity you fetch is that you set in IB for the tree
controller, so that is *kind of* asking the context, "get me the nodes
in the tree controller", but not exactly as the tree controller itself
may have a predicate that causes it to fetch only some of those types
of entities. The fetch request (if you set the same predicate as the
you have for the tree controller) will get you your NSSet of objects,
then you can do whatever you want with the objects.
HTH,
Jon
DATE : Sat May 31 22:26:02 2008
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
returns the top-level objects in the tree (NSTreeController.h assures
me that -arrangedObjects responds to -childNodes, this differs from
what the docs say).
// NSTreeController_Extensions
- (NSArray *)rootNodes;
{
return [[self arrangedObjects] childNodes];
}
now it'll work!.
> 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, whatever you
>> may or may not have used in the tree controller).
>> 5 - Set the fetch request's predicate to the above if any.
>> 6 - Execute the fetch request and get the last (or first) object of
>> the results (checking for errors, minding the set-versus-array
>> gotchas, etc.).
>
>
> Wow, really? No way to just get at all the items in the tree
> controller with some key path, then use @max?
Think of this this way, only the tree controller knows which objects
it has in it. The context and the model objects are ignorant of
this. The entity you fetch is that you set in IB for the tree
controller, so that is *kind of* asking the context, "get me the nodes
in the tree controller", but not exactly as the tree controller itself
may have a predicate that causes it to fetch only some of those types
of entities. The fetch request (if you set the same predicate as the
you have for the tree controller) will get you your NSSet of objects,
then you can do whatever you want with the objects.
HTH,
Jon
| Related mails | Author | Date |
|---|---|---|
| Rick Mann | May 31, 11:35 | |
| Jonathan Dann | May 31, 11:57 | |
| Rick Mann | May 31, 20:47 | |
| I. Savant | May 31, 21:05 | |
| Rick Mann | May 31, 22:12 | |
| Jonathan Dann | May 31, 22:26 | |
| I. Savant | May 31, 22:36 | |
| Jonathan Dann | May 31, 23:28 |






Cocoa mail archive

