• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTreeController Filtering
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController Filtering


  • Subject: Re: NSTreeController Filtering
  • From: Noah Lieberman <email@hidden>
  • Date: Mon, 25 Jul 2005 10:51:24 -0700

Todd,

Thanks, this really helps. It's not working yet, but it's a step in the right direction. I've got it working using bindings and the NSArrayController's filterPredicate, so no need to implement mmalc's old filtering array controller. The trouble is, because we need to use a parent==nil predicate so the tree works right, the search only works on top level objects... :) I can see where this is going to get tricky. If we find a child object that matches the search criteria we would presumably need to show all of it's parents back up the top level and show them all expanded...

Any more strokes of genius? :)



On 21-Jul-05, at 19:43 , Todd Blanchard wrote:

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:
40cocoadoc.com


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
References: 
 >NSTreeController Filtering (From: Noah Lieberman <email@hidden>)
 >Re: NSTreeController Filtering (From: Scott Anguish <email@hidden>)
 >Re: NSTreeController Filtering (From: Todd Blanchard <email@hidden>)

  • Prev by Date: Re: Which Frameworks? /Developer/SDK 10.4/System/Library/Frameworks vs System/Library/Frameworks
  • Next by Date: Re: Which Frameworks? /Developer/SDK 10.4/System/Library/Frameworks vs System/Library/Frameworks
  • Previous by thread: Re: NSTreeController Filtering
  • Next by thread: flipping the y-axis of an nsimage
  • Index(es):
    • Date
    • Thread