Instance Method

start(completionHandler:)

Starts the search and delivers the results to the specified completion handler.

Declaration

func start(completionHandler: @escaping MKLocalSearch.CompletionHandler)

Parameters

completionHandler

The completion handler block that processes the results. This parameter must not be nil.

Discussion

You use this method to initiate a map-based search operation. The search runs until the results are delivered, at which point the specified completion handler is called.

You should call this method only once to start the search operation. Calling this method while the search is running does not stop the original search operation from finishing. However, for each subsequent call, the search object executes your completion handler and passes an error object to it.

The provided completion handler is always executed on your app’s main thread. The local search object keeps a reference to the completion handler block until the results (or an error) are delivered, at which point it relinquishes that reference.

See Also

Performing the Search

typealias MKLocalSearch.CompletionHandler

A completion handler block for a search operation.

class MKLocalSearch.Response

The results from a map-based search.

var isSearching: Bool

A Boolean indicating whether the search is currently in progress.

func cancel()

Cancels an in-progress search operation.