Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: filtering a list like address book



I'm assuming your nav aids list will have an array controller and that you're building for Tiger or better.

You really shouldn't. A number of reasons for this presented themselves on this very list within the last few weeks.


You can get the search behavior by adding a search field to your interface and binding the search field's predicate to the array controller's filterPredicate. It will then filter your array of nav aids in real time, and there's no code necessary -- it's all done in IB.

This is absolutely true, but a warning: it requires a good, solid understanding of the most basic Cocoa design patterns, as well as some moderately-advanced topics like Key-Value Coding (KVC) and Key-Value Observing (KVO), so you can grasp the Bindings mechanism (upon which NSArrayController relies). If you don't have this foundation, you're in for a world of hurt going down this path prematurely.


http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html

Thankfully, predicates work just fine without Bindings. If you have a good understanding of KVC, you can filter an array and use the approach Nick Zitzmann previously suggested.


Well, with one minor adjustment. Use the -[NSControl controlTextDidChange:] delegate method instead of a timer. Trigger your filtration each time it's called by your search field.

--
I.S.


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >filtering a list like address book (From: Mark Bateman <email@hidden>)
 >Re: filtering a list like address book (From: Nick Zitzmann <email@hidden>)
 >Re: filtering a list like address book (From: August Trometer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.