NSTreeController Filtering
NSTreeController Filtering
- Subject: NSTreeController Filtering
- From: Noah Lieberman <email@hidden>
- Date: Thu, 21 Jul 2005 11:24:22 -0700
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