Re: NSTreeController Filtering
Re: NSTreeController Filtering
- Subject: Re: NSTreeController Filtering
- From: Todd Blanchard <email@hidden>
- Date: Thu, 21 Jul 2005 19:43:23 -0700
Given that this is shown as an officially sanctioned example using an
NSArrayController subclass, I find this "opaque" position to be
completely insane.
However, for the benefit of poor Noah, victim of this madness, let me
suggest that you create an NSArrayController to obtain the root level
objects for your tree (set a predicate parent==nil or something on
it), do the filtering trick as shown on mmalc's site on that, then
bind the contentArray of the NSTreeController to the
FilteredArrayController's arrangedObjects.
On Jul 21, 2005, at 3:16 PM, Scott Anguish wrote:
the arrangedObjects for NSTreeController are totally opaque. You
should not assume, ,or expect, them to be of any specific class.
On Jul 21, 2005, at 2:24 PM, Noah Lieberman wrote:
Hello,
I'm trying to make a subclass of NSTreeController that will allow
me to do filtering using a search field. I can't believe that
filterPredicate wasn't implemented in NSTreeController... Anyway,
I've looked at some posts on cocoabuilder, and done some reading
and I found people talking about using the private method
"observedObject" to try and get around the proxy object issue. But
I'm having trouble.
I implemented filterPredicate and setFilterPredicate methods, and
overrode arrangedObjects:
- (id)arrangedObjects
{
//TODO, keep in mind that observedObject is a private
method... there should be a better way to do
//this but, arrangedObjects is returning a proxy instead of an
actuall array
id arrangedObjectsProxy = [super arrangedObjects];
id arrangedObjectsArray = [arrangedObjectsProxy
observedObject]; //This doesn't work
if([self filterPredicate] != nil)
{
return [arrangedObjectsArray filteredArrayUsingPredicate:
[self filterPredicate]];
}
else
{
return arrangedObjectsArray;
}
}
This fails though because apparently the arrangedObjects method
returns an _NSControllerTreeProxy, which does not respond to the
observedObject method. However, in order to get a filtered array,
I have to have an array... This initially seemed like it should be
simple, but perhaps is not...
Any suggestions? What's the recommended method for creating a
filtering tree controller, the header file specifically indicates
that they expect people to do this, and to use rearrangeObjects to
trigger it... however it would sure be nice to be able to use the
search bindings of a search field to set the filterPredicate...
Thanks,
Noah
_______________________________________________
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
_______________________________________________
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
_______________________________________________
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