I need to draw a path starting with a list of coordinates (P1, P2, ... Pn). For each next couple Pi, Pj of my list I call the method calculateDirectionsWithCompletionHandler
of the class MKDirections
until the Pn-1 element. The first time I call it everything looks perfect.
But if I call a second time or further I got this error:
Error Domain=MKErrorDomain Code=3 "Directions Not Available" UserInfo={NSLocalizedFailureReason=Route information is not available at this moment., MKErrorGEOError=-4, MKDirectionsErrorCode=2, NSLocalizedDescription=Directions Not Available}
and nothing works anymore.
I think this happens because I call the API too many times in a short time. I found on the web I should use the attribute direction.calculating
and check if a request is already in progress. I cannot understand how to use it. Anybody can help me? Thank you.