The NCWidgetSearchViewController class provides a default search view within a widget (a widget is an extension in the Today view of Notification Center). A search view controller works together with its delegate to perform searches on the user’s input and display results from which a user can choose. To learn about the search view controller delegate methods, see NCWidgetSearchViewDelegate.


When a widget is in editing mode, it can enable search for new content by instantiating an NCWidgetSearchViewController object and presenting it using presentViewControllerInWidget:. The search view controller displays the default search field and a list of results. It uses its delegate to perform the search itself.


Accessing the Delegate

var delegate: NCWidgetSearchViewDelegate?

The search view controller’s delegate or nil if the receiver doesn’t have a delegate.

Displaying the Search Interface

var searchDescription: String?

A localized description of the nature of the search.

var searchResultsPlaceholderString: String?

A localized phrase displayed in the results list when no search results are available.

Displaying Search Results

var searchResultKeyPath: String?

A key path for the string property to display for each object in the search results array.

var searchResults: [Any]?

An array of search results.