문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top