The process of converting latitude and longitude into human readable address is called Reverse GeoCoding.
If you are developing an iOS app in which app allows its user to select the location on map. Then surely you will need to convert the selected latitude and longitude into human readable address by using reverse geocoding, in order to show what address does user has selected. The code for reverse geocoding is pretty straight forward.
In case if you want to use Google's GMSGeocoder
then most probably you will run into a situation where you want to entertain the last request only. Didn't understand what I mean? Lets consider the following scenario:
As the requests are asynchronous, this means there is no guarantee which request will be completed first. So, in this particular case you need to cancel the outstanding reverse geocoding requests before making new requests. But guess what? there is no cancel method for GMSGeocoder
.
Luckily this can be solved by adding 1 simple logic, found here. We can modify our reverse geocoding helper function to entertain the last request only and ignore all outstanding stale requests. Here is the code.
Enjoy!
Cocoapods is a popular dependency manager among iOS developers. iOS developers often use Cocoapods for integrating third party libraries. It provides different hooks to perform certain custom actions.
Muhammad Zeeshan
Want to get in touch? Feel free to contact me at