Domanda

I have an array of street addresses, I want my app to sort that array starting with the closest address to my location (GPS).

Now that Apple has released iOS Maps in iOS 6, what is the easier way to do that?

Thanks, Matt.

È stato utile?

Soluzione

Approach I'd take would be use CLGeocoder to obtain CLLocation instances for each address (there are several async methods provided by the class to do this). Save the values obtained if needed for future sorts to save having to re-obtain them. Get your location as a CLLocation instance. Use -[ CLLocation distanceFromLocation: ] to obtain distance between your device location and each address location. Sort on these distance values.

Hope this helps! Mark

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top