Contents

start(completionHandler:)

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

Declaration

func start(completionHandler: @escaping @MainActor @Sendable (MKLocalSearch.Response?, (any Error)?) -> Void)
func start() async throws -> MKLocalSearch.Response

Parameters

  • completionHandler:

    The completion handler block that processes the results. This parameter can’t be nil.

Discussion

You use this method to initiate a map-based search operation. The search runs until the framework delivers the results, at which point the framework calls the specified completion handler.

Call this method only once to start the search operation. Calling this method while the search is running doesn’t 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 executes on your app’s main thread. The local search object keeps a reference to the completion handler block until the search object delivers the results (or an error), at which point, it relinquishes that reference.

See Also

Performing the search