On May 28, 2005, at 11:08 AM, Justin Fagnani wrote:
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.
It's pretty hard to follow this without seeing how you have things laid out, but I *think* you could do this by implementing a custom method like:
- (NSSet *) parentTypes
{
return [self valueForKeyPath:@"parent.types"];
}
You could then bind the ParentTypes array controller to the Types array controller, with the "selection" controller key and "parentTypes" as the model key path.
Does that do what you want?
I figure that I could filter the selected object with a predicate of "self != ????" well, what do I put there? Types.selection?
I think I get what you're after at a high level, but I'm not sure how to answer because I can't see how this all fits together. I don't think this is a predicate problem per say; you may just need a different approach.
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.
I'm not sure 'self' would work here.
And the predicate for a controller doesn't have a GUI, so I'm not sure yet how to place a variable.
You can always use Xcode's predicate editor to create a predicate, then just copy and paste it elsewhere.
Even then, how do I set that variable?
You'd set the predicate programatically, not in Interface Builder.
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?