Question

My app needs to know the rough location of a user, with a resolution of their state/province. This way we know what the default tax rate should be in a simple tax calculator. They can still pick it after that, but its always nice to try to get it right.

Is there an easy way to get this sort of resolution without all the rigamarole of callbacks and such? I don't need updates, a single rough location will do, and an old one is likely perfectly fine.

Was it helpful?

Solution

There are no short simple ways to get current location.
That means that you need init CLLocationManager object, call startUpdatingLocation method and retrieve result in delegate method.
It's impossible to get current location synchronously by using one line of code because retrieving location info could take much time (For example turning on GPS sensor and so on.). That's why you get info by asynchronous delegate methods.

OTHER TIPS

is the only way,

but to get a single user position within the method locationManager:didUpdateLocations: call stopUpdateLocation:

[locationManager stopUpdatingLocation]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top