<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSearchFieldCell",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSearchFieldCell"
  },
  "title" : "NSSearchFieldCell"
}
-->

# NSSearchFieldCell

The programmatic interface for text fields that are used for text-based searches.

```
class NSSearchFieldCell
```

## Overview

The [`NSSearchFieldCell`](/documentation/AppKit/NSSearchFieldCell) class defines the programmatic interface for text fields that are optimized for text-based searches. An [`NSSearchFieldCell`](/documentation/AppKit/NSSearchFieldCell) object is “wrapped” by an [`NSSearchField`](/documentation/AppKit/NSSearchField) control object, which directly inherits from the [`NSTextField`](/documentation/AppKit/NSTextField) class. The search field implemented by these classes presents a standard user interface for searches, including a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories.

When the user types and then pauses, the cell’s action message is sent to its target. You can query the cell’s string value for the current text to search for. Do not rely on the sender of the action to be an [`NSMenu`](/documentation/AppKit/NSMenu) object because the menu may change. If you need to change the menu, modify the search menu template and update the value in the [`searchMenuTemplate`](/documentation/AppKit/NSSearchFieldCell/searchMenuTemplate) property.

## Topics

### Managing buttons

[`searchButtonCell`](/documentation/AppKit/NSSearchFieldCell/searchButtonCell)

The button cell used to display the search-button image.

[`-  resetSearchButtonCell`](/documentation/AppKit/NSSearchFieldCell/resetSearchButtonCell())

Resets the search button cell to its default attributes.

[`cancelButtonCell`](/documentation/AppKit/NSSearchFieldCell/cancelButtonCell)

The button cell used to display the cancel-button image.

[`-  resetCancelButtonCell`](/documentation/AppKit/NSSearchFieldCell/resetCancelButtonCell())

Resets the cancel button cell to its default attributes.

### Custom layout

[`-  searchTextRectForBounds:`](/documentation/AppKit/NSSearchFieldCell/searchTextRect(forBounds:))

Modifies the bounding rectangle for the search-text field cell.

[`-  searchButtonRectForBounds:`](/documentation/AppKit/NSSearchFieldCell/searchButtonRect(forBounds:))

Modifies the bounding rectangle for the search button cell.

[`-  cancelButtonRectForBounds:`](/documentation/AppKit/NSSearchFieldCell/cancelButtonRect(forBounds:))

Modifies the bounding rectangle for the cancel button cell.

### Managing menu templates

[`searchMenuTemplate`](/documentation/AppKit/NSSearchFieldCell/searchMenuTemplate)

The menu object used to dynamically construct the search field’s pop-up icon menu.

### Managing search modes

[`sendsWholeSearchString`](/documentation/AppKit/NSSearchFieldCell/sendsWholeSearchString)

A Boolean value indicating whether the cell calls its search action method when the user clicks the search button (or presses Return) or after each keystroke.

[`sendsSearchStringImmediately`](/documentation/AppKit/NSSearchFieldCell/sendsSearchStringImmediately)

A Boolean value indicating whether the cell calls its action method immediately when an appropriate action occurs.

### Managing recent search strings

[`maximumRecents`](/documentation/AppKit/NSSearchFieldCell/maximumRecents)

The maximum number of search strings that can appear in the search menu.

[`recentSearches`](/documentation/AppKit/NSSearchFieldCell/recentSearches)

An array of the recent search strings to display in the pop-up icon menu of the search field.

[`recentsAutosaveName`](/documentation/AppKit/NSSearchFieldCell/recentsAutosaveName)

The autosave name under which the search field automatically saves the list of recent search strings.

### Constants

[Menu tags](/documentation/AppKit/menu-tags)

Constants for identifying special menu items in the search-menu template.

### Initializers

[`-  initWithCoder:`](/documentation/AppKit/NSSearchFieldCell/init(coder:))

[`-  initTextCell:`](/documentation/AppKit/NSSearchFieldCell/init(textCell:))

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSTextFieldCell`](/documentation/AppKit/NSTextFieldCell)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)