Skip to end of metadata
Go to start of metadata

Built upon iOS 8's new search controller, UISearchController<TViewModel> provides comprehensive data binding capability between the search controller and the underlying ViewModel. It allows you to instantiate a search controller with just simple constructors, while automatically leveraging the search logic already defined in the ViewModel. The search controller works in the same way and manner as in the classic search bar within a table view controller.

For more information about implementing search in ViewModel, see Implement Searchable List.
The following figure shows the concept overview of the search controller.

On this page:

Using UISearchController

Leveraging the new presentation feature in iOS 8, UISearchController is a modal presenter which should be navigated with Modal mode. Typically, you will navigate to the search controller in the ViewModel, such as in the search command delegate which is raised when user tapped on the search button.

The following code example shows how to navigate to the search controller by specifying the associated ViewModel type and navigation identifier. The example also shows how to capture and process the result data when a search item is selected.

In the iOS project, here's the code example that defines the search controller.

As seen in the above code, the search controller requires only constructors to instantiate the required view. The actual searching logic is defined entirely in the ViewModel, enabling 100% code reuse for other platforms such as Android and Windows.


To learn how to implement the search controller that complies with best practices, please refer to the sample: