CoreData: filtering controller content
CoreData: filtering controller content
- Subject: CoreData: filtering controller content
- From: Justin Fagnani <email@hidden>
- Date: Sat, 28 May 2005 11:08:28 -0700
I have some data that's very much like a class hierarchy. Each object
has a parent. I have a pop-up button for selecting the parent, but
I'd like to remove the target object and any of it's descendants from
the list so that there's no possibility of loops.
I guess this is similar to the question I asked a little while ago
about getting all descendants in an NSTreeController[1], and will
probably have a similar solution, but I've been trying to figure out
ways to do this with out writing code using just an additional
controller and predicates.
What I think I'm finding is that the predicate syntax is not as well
suited for working with trees as other expression languages. XPath,
for instance, has the ancestors and descendants axes.
I actually can't even figure out how to filter out the object I'm
editing from the list of types. The object is selected in an
ArrayController called Types. I want a second ArrayController called
ParentTypes to contain all the valid choices for a parent. I figure
that I could filter the selected object with a predicate of "self !
= ????" well, what do I put there? Types.selection? The predicate
builder for fetched requests has a way to place a variable in the
predicate, but I can't seem to compare self to a variable. And the
predicate for a controller doesn't have a GUI, so I'm not sure yet
how to place a variable. Even then, how do I set that variable?
So this leads me to another solution where I subclass NSManagedObject
and create a property called something like
objectsNotSelfOrDescendent. To save some work I can add this to my
previous subclass and call it a ManagedTreeObject. Ok that's not too
bad I guess. However, for some reason I think of this as really
extending the behavior of the controller. I'm tempted to subclass
NSTreeController and add methods for retrieving objects along the
different axes. Good idea or bad idea?
Any thoughts on this?
Thanks,
-Justin
[1]: http://www.cocoabuilder.com/archive/message/cocoa/2005/5/24/136900
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden