Re: Predicates
Re: Predicates
- Subject: Re: Predicates
- From: "Ken Ferry" <email@hidden>
- Date: Thu, 27 Dec 2007 11:49:56 -0500
Hi Keith,
The search field documentation doesn't explain the concept of
target-action inline because it's one of a small number of patterns
that underly all of Cocoa.
See "The Target-Action Mechanism",
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_5.html#//apple_ref/doc/uid/TP40002974-CH7-SW14>.
You will not likely have much luck with Cocoa programming until you've
read the "Communicating With Objects" section of the Cocoa
Fundamentals guide, which is the section that contains the section on
target-action. The rest of the docs assume you understand the
fundamentals.
It's short. :-)
-Ken
On Dec 27, 2007 11:09 AM, Keith Penrod <email@hidden> wrote:
>
>
> On Dec 26, 2007, at 9:40 PM, mmalc crawford wrote:
>
> >
> > 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
> >
>
> I'm sorry, but that is the entire reason I never read Apple's
> documentation. The article about target-action doesn't say anything
> at all about how to configure the search box, only that it's something
> you should do. I've already set up the binding properly, so the
> search box works fine--but only when it's non-empty. If I could
> figure out a way to make the search box actually do something when
> it's empty or figure out where I need to implement this action that's
> apparently notified when the search field changes, then I'd be great.
> But that's exactly what I have no idea how to do, and none of the
> articles listed say anything about that.
>
> Keith
>
> _______________________________________________
>
> 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
>
_______________________________________________
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