Cannot wait for the result of MKDirections.calculate, getting nil instead of it
问题 I would like to calculate the real walking distance between my current location and a list of CLLocation s using MKDirections.calculate . However, for some reason the return command at the end of the function does not wait for the result and tries to return the empty variable. My code looks like this: func getDistance (location1: CLLocation, location2: CLLocation) { let coordinates1 = location1.coordinate let placemark1 = MKPlacemark(coordinate: coordinates1) let sourceItem = MKMapItem