calculate(completionHandler:)
Begins calculating the requested route information asynchronously.
Declaration
func calculate(completionHandler: @escaping @Sendable (MKDirections.Response?, (any Error)?) -> Void)func calculate() async throws -> MKDirections.ResponseParameters
- completionHandler:
The block to execute when the directions are ready or when an error occurs. This parameter can’t be
nil.
Discussion
This method initiates the request for directions and calls your completion handler block with the results. The method executes your completion handler on your app’s main thread. The implementation of your handler needs to check for errors and then incorporate the response data as appropriate.
If you call this method while a previous request is in process, this method calls your completion handler with an error. You can determine whether a request is in process by checking the value of the isCalculating property. You can also cancel a request as necessary.