CLLocationManager

Discussion in 'iOS Programming' started by MACloop, Dec 16, 2009.

  1. MACloop macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #1
    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
     
  2. Colonel Badger macrumors 6502

    Joined:
    Jun 30, 2008
    #2
    Yes thats a legit way to do it.
     
  3. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
  4. Colonel Badger macrumors 6502

    Joined:
    Jun 30, 2008
    #4
    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.
     

Share This Page