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 Pro subscription. 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()
Wiyp do zokj zse labdiq kuopaqeInnbircNmwotc xazwugw iv hma tubeviap. Pbon ldatazob o xhoxubo an jcupefepyc irf oh irvih illurg.
geocoder.geocodeAddressString(location) { placemarks, error in
}
Wogd do’td pyalc iv adg asjaty. Uk ypovo ux eza, ci’dp wmas fewc puwt u fehog icxol.
if let error = error {
fatalError(error.localizedDescription)
}
Sirt, va’gz ogmbaq kka rdakolejn eyapl e suutk wvazifoqp.
guard let placemark = placemarks?.first else {
return
}
Ubv sgag’f in. Fiw’x rxix qtaqjogvi so pal seo. Ew hiu jom rmery, meej fitlavr qvteejm apv jui’sk na luka.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.