Re: Predicates
Re: Predicates
- Subject: Re: Predicates
- From: mmalc crawford <email@hidden>
- Date: Wed, 26 Dec 2007 20:40:50 -0800
On Dec 26, 2007, at 8:14 PM, Keith Penrod wrote:
In Interface Builder. I just type it into the "fetch predicate" box
in the inspector window. I'm currently trying to figure out how I
can make an outlet in the controller class that links to the search
field and tells it to update the fetchPredicate when it notices a
change in the search box, but I'm not sure how to do that.
Sorry, but this shows precisely why it's important to learn Cocoa's
design patterns etc. in an ordered fashion. If you start to try to
use frameworks that are labeled as "advanced" without having mastered
the basics, then you won't know where or how to customise your
application...
There are two ways to set up the search field, using target-action or
using bindings (see <http://developer.apple.com/documentation/Cocoa/Conceptual/SearchFields/Articles/ConfiguringTargetAction.html#//apple_ref/doc/uid/20002073
> and <http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/Concepts/BindingTypes.html#//apple_ref/doc/uid/20002305-216985
> respectively).
In either case, you can implement the set accessor method (that's
invoked when the search field changes) to update the tree controller's
fetch predicate accordingly (you need an outlet to the controller,
then send it setFetchPredicate: <http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSObjectController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObjectController/setFetchPredicate:
>). If there's no predicate associated with the search field, then
the predicate should be "parent==nil", otherwise it's whatever is in
the search field. You can then re-fetch the tree controller's content
(<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSObjectController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObjectController/fetch:
>).
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden