Class

CPSearchTemplate

A template that displays a destination search screen.

Declaration

class CPSearchTemplate : CPTemplate

Overview

Use this template to let the user search for a destination. When CarPlay displays the template, the user sees a search field, a cancel button, and a localized keyboard. The template also shows the list of search results after your app completes the search request.

To use a search template, create an instance of CPSearchTemplate and set its delegate to an object that conforms to the CPSearchTemplateDelegate protocol. Push the template onto the navigation stack by calling pushTemplate(_:animated:) on the interface controller. This presents the search template to the user.

As the user enters text into the search field, the system calls the delegate method searchTemplate(_:updatedSearchText:completionHandler:), indicating that your app should retrieve the search result. After retrieving the results, call completionHandler, returning an array of CPListItem objects—one list item for each search result item.

When the user selects an item from the search result, the system calls the searchTemplate(_:selectedResult:completionHandler:) method on the delegate object. The delegate performs any necessary operations to process the selected item, then calls the completion handler to let the system know it may continue.

Topics

Providing a Search Template Delegate

var delegate: CPSearchTemplateDelegate?

The object that serves as the search template's delegate.

protocol CPSearchTemplateDelegate

The interface for an object that serves as the search template’s delegate.

Relationships

Inherits From

Conforms To