Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MACloop

macrumors 6502
Original poster
May 18, 2009
393
0
Germany
Hi,
I am using a location manager in my app only with purpose to get my own current coordinates. This means that I do not want the location update to go on, but only to get the coordinates on application load. So my question is if it is a proper way to use the CLLocationManager as following pseudo-code?

init a locationmanager and configure it like with desiredAccuracy etc.

Start the location manager.

In the delegate method didUpdateToLocation -> stop the location manager and use the coordinates assigned to a variable, i.e CLLocation *yourCurrentLocation

If this is not the way to do it - can anyone please give me an example on how to do it right? I have only found examples like LocateMe which has a on/off button to control the location manager....

Thanks in advance
MACloop
 
Hi,
I am using a location manager in my app only with purpose to get my own current coordinates. This means that I do not want the location update to go on, but only to get the coordinates on application load. So my question is if it is a proper way to use the CLLocationManager as following pseudo-code?

init a locationmanager and configure it like with desiredAccuracy etc.

Start the location manager.

In the delegate method didUpdateToLocation -> stop the location manager and use the coordinates assigned to a variable, i.e CLLocation *yourCurrentLocation

If this is not the way to do it - can anyone please give me an example on how to do it right? I have only found examples like LocateMe which has a on/off button to control the location manager....

Thanks in advance
MACloop

Yes thats a legit way to do it.
 
Thanks alot! :)
MACloop

Make sure that if you're interested in a particular accuracy that you wait to get it before stopping CLLocation. Its possible for CLLocation to give you lower accuracy first (although events aren't guaranteed to arrive in order) so keep checking until you have the desired accuracy.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.