Mac Developer Library

Developer

AppKit Framework Reference NSSearchField Class Reference

Options
Deployment Target:

On This Page
Language:

NSSearchField

An NSSearchField object implements a text field control that is optimized for performing text-based searches. The control provides a customized text field for entering search data, a search button, a cancel button, and a pop-up icon menu for listing recent search strings and custom search categories.

An NSSearchField object wraps an NSSearchFieldCell object. Access to most search field attributes occurs through the cell, which provides a more comprehensive programmatic interface for manipulating the search field. You can use an NSSearchField object though to manipulate some aspects of the search field. For additional information about search fields and how to manipulate them, see the NSSearchFieldCell class.

Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.3 and later.
  • Sets the list of recent search strings to list in the pop-up icon menu of the receiver.

    Declaration

    Swift

    var recentSearches: [AnyObject]

    Objective-C

    @property(copy) NSArray *recentSearches

    Parameters

    searches

    An array of NSString objects containing the search strings.

    Discussion

    You might use this method to set the recent list of searches from an archived copy.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the list of recent search strings for the control.

    Declaration

    Swift

    var recentSearches: [AnyObject]

    Objective-C

    @property(copy) NSArray *recentSearches

    Return Value

    An array of NSString objects, each of which contains a search string either displayed in the search menu or from a recent autosave archive. If there have been no recent searches and no prior searches saved under an autosave name, this array may be empty.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets the autosave name under which the receiver automatically archives the list of recent search strings.

    Declaration

    Swift

    var recentsAutosaveName: String?

    Objective-C

    @property(copy) NSString *recentsAutosaveName

    Parameters

    name

    The autosave name, which is used as a key in the standard user defaults to save the recent searches. If you specify nil or an empty string for this parameter, no autosave name is set and searches are not autosaved.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the key under which the prior list of recent search strings has been archived.

    Declaration

    Swift

    var recentsAutosaveName: String?

    Objective-C

    @property(copy) NSString *recentsAutosaveName

    Return Value

    The autosave name, which is used as a key in the standard user defaults to save the recent searches. The default value is nil, which causes searches not to be autosaved.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.