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.
Searching for an address - iOS Tutorial
From the course: Advanced iOS App Development: MapKit & Core Location
Searching for an address
- [Instructor] We found an address from a coordinate. It's now time to find a coordinate from an address through geocoding and the geocode address string method. Head over to the View controller. You'll find another mark for Find in our instance methods, and head over there. Add a new function, including a string and closure, as parameters. Going to do func, getCoordinate. Our first parameter will be address. That's going to be string. Our second will be completionHandler, and that's going to be an escaping closure. A CLLocationCoordinate2D. And that's an optional string, an NSError, and option returning nothing. We'll need a geocoder instance, so instantiate one. Then add the geocode address string method, which has a closure that results in an array of CL place marks, and an error code which you'll need to process in the closure. So I'm going to do geocoder. Geocode. Address string with completion handler. And that'll be an address, and a completion handler. We need place marks…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.