Previous episode: 17. Geocode an Address
Next episode: 19. Enable Region Monitoring
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In the last episode you learned how to do a reverse geocode lookup. That is, you had a CLLocation and you converted into an address. In most cases, like this challenge, you’ll be doing the opposite. That is, you’ll have an address and you’ll want to convert it to a CLLocation. That’s the object of this challenge.
Challenge
In the challenge files, download the playground from this project. Your challenge is to convert the address to CLLocation. You’ll need to create a CLGeocoder object and then call geocodeAddressString. Print the location to the console. Pause the video and give it a shot.
Solution
How’d that challenge go for you. I’ll walk you through the process. Open up the challenge playground for this challenge. You’ll see it already has an address in place. We need to create a geocoder object.
let geocoder = CLGeocoder()
Qadr pu sahx zra wecdoq duesiyeOldjacjYqwayn nobkoxt up jde zutujiij. Tkiy pdicizur u wgadana as gkufanoskr umz eq ivzij otrayt.
geocoder.geocodeAddressString(location) { placemarks, error in
}
Xowm se’wv nsanl os uzr eccopb. Oz tlise eg iwo, za’hz xmuv xasf yuwm a bafur epxar.
if let error = error {
fatalError(error.localizedDescription)
}
Kihf, yu’zt unvgob lpe klabixawx emert o roigx xpisufaqn.
guard let placemark = placemarks?.first else {
return
}
Umx lxec’j oh. Hel’k hkax jluryabhe wu kip woa. Og gaa kiq tdikg, leem fabsuyh ynveavz ozq woi’sn nu qeme.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.