<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.2.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKit",
  "identifier" : "/documentation/MapKit/MKDirections/calculate(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit"
    ],
    "preciseIdentifier" : "c:objc(cs)MKDirections(im)calculateDirectionsWithCompletionHandler:"
  },
  "title" : "calculate(completionHandler:)"
}
-->

# calculate(completionHandler:)

Begins calculating the requested route information asynchronously.

```
func calculate(completionHandler: @escaping @Sendable (MKDirections.Response?, (any Error)?) -> Void)
```

## Parameters

`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`](/documentation/MapKit/MKDirections/isCalculating) property. You can also cancel a request as necessary.

## See Also

[`calculating`](/documentation/MapKit/MKDirections/isCalculating)

A Boolean value that indicates whether a request is in process.

[`-  cancel`](/documentation/MapKit/MKDirections/cancel())

Cancels a pending request.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)