---
title: Introduction to Search Fields
framework: cocoa
role: article
path: apple-archive/documentation/Cocoa/Conceptual/SearchFields
---

# 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](Articles/AddingSearchField.html#//apple_ref/doc/uid/20002244-BABFIBIA) .

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](Articles/AddingSearchField.html#//apple_ref/doc/uid/20002244-BABFIBIA) .

To learn how to implement suitable methods in the search field’s target, read [Adding a Search Field to Your Application](Articles/AddingSearchField.html#//apple_ref/doc/uid/20002244-BABFIBIA) .

To learn how to change the appearance of a search field programatically, read [Customizing Your Search Field’s Appearance](Articles/CustomizingSearchFields.html#//apple_ref/doc/uid/20002246-BABFIBIA) .

## See Also

- *OS X Human Interface Guidelines* provides guidelines on when to use particular interface items and how to position them. - *[Search Kit Reference](https://developer.apple.com/documentation/coreservices/search_kit)* describes a powerful and streamlined C language framework for indexing and searching text in most human languages.

[Next](Articles/AddingSearchField.html)

Copyright © 2003, 2012 Apple Inc. All Rights Reserved. [Terms of Use](http://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](http://www.apple.com/privacy/) | Updated: 2012-07-23
