From the course: Advanced iOS App Development: MapKit & Core Location

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Display graphic directions

Display graphic directions - iOS Tutorial

From the course: Advanced iOS App Development: MapKit & Core Location

Start my 1-month free trial

Display graphic directions

- [Instructor] You've made a request and asked the Apple servers to send you directions between two points. In the closure for the calculate method, you have a parameter response, which is of type MKDirections response, and your directions. You'll need to do a bit of unwrapping of this object, depending on what you want on your map. We'll start with tracing the route on the map. The property response is optional. So, unwrap it first. There's only three properties in MKDirections response, your source and destination points, and an array of routes named routes. If you get this far, there will be at least one route in this array. Both response and error would be nil otherwise. I'll get the routes and print the count to the console. Let routes equal... response dot... routes. And we can print the count out nice and simply. Print... Backslash... routes dot count. After that, I'll loop through the routes and put them on the map for... route in... routes. MK routes has descriptive…

Contents