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).
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.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
This email sent to email@hidden