Introduction to Search Fields
Explains how to use Cocoa search fields.
At a Glance
A search field is implemented by two classes: NSSearchFieldCell , the cell that does most of the work, and NSSearchField , the control that contains that cell.
There are, broadly speaking, two ways to configure and use a search field—programmatically, or with Cocoa bindings.
If you configure a search field programmatically, you should set the target and action of the control or its cell to the receiver that is interested in the search request. Also, remember that NSSearchFieldCell and NSSearchField classes are direct subclasses of NSTextFieldCell and NSTextField , respectively, so you can use all the methods inherited from these classes.
If you use bindings, you typically set the multi-value Predicate binding to set the predicates on a controller such as an instance of NSArrayController .
You can, of course, mix these approaches—for example, you may need to programmatically update the Predicate binding if you dynamically change the search categories based on the visibility of columns in a table view.
How to Use This Document
To learn how to add a search field to your application, using either a xib file or in code, read Adding a Search Field to Your Application .
To learn how to set up the search field’s pop-up icon menu to show recent search strings and search categories, read Adding a Search Field to Your Application .
To learn how to implement suitable methods in the search field’s target, read Adding a Search Field to Your Application .
To learn how to change the appearance of a search field programatically, read Customizing Your Search Field’s Appearance .
See Also
Search Kit Reference describes a powerful and streamlined C language framework for indexing and searching text in most human languages.
Next
Copyright © 2003, 2012 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2012-07-23