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

sid.bond.86

macrumors newbie
Original poster
Oct 8, 2010
4
0
Hi,

I am writing a simple program for iphone, in which i just need to get the current location and put it in the label.

Now , I just want the current location and not the update location function.
I just need to poll the GPS coordinates and print it in a label. I do not want to use the didUpdateToLocation function. I want to get the lat/long at one instance and print it.

Please help!

Sid
 
What you want cannot be done. It takes some time for the GPS to get a fix on the current location. So you must start it off and wait for callbacks in didUpdateToLocation.
 
hey robbie,
thanks for the quick response.

Hmm.. if this is not possible, is there an y way that i can call this update function every 1 sec.

So basically what my goal is to print the current location of a iphone every second on the screen, even if the location of the iphone has not changed.

Please guide me as to how i can achieve this.

Sid
 
Then simply have a variable that holds the current/last reported position. Every time didUpdateToLocation is called then update the variable. Pretty simply really.
 
Hmmm... thnks.. let me try it..
actually this is my first iphone program.
so i am having hard time figuring it out :(
 
Create an class object that updates its state using didUpdateToLocation.

Then when you want to update your label (every second), just send a query message to that object to get the last state update.
 
Just FYI: didUpdateToLocation is called once per second in iOS 4* (whether or not the phone is in motion).

* In previous iOS versions the update frequency was not so regular.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.