views:

259

answers:

2

Hi folks,

I was trying to make a sample iphone application to update current location. I have a function that logs the current location, "logCurrentLocation", but I have no idea how to call this function automatically in every X minutes( or seconds).

Please advise me which method I need to look at in the apple documentation.

Thank you for your help.

sung.

+1  A: 

Hi sungl,

Check out the documentation for NSTimer. It allows you to schedule a timer which will call a function (defined by a "Target" object and a "Selector" you want to call). You can change the interval at which the timer fires, and it should do the trick!

Ben Gotow
Thanks for quick reply. You guys are rock!
sungl
+2  A: 

You need to set an NSTimer, have a look at this sample app

The timer in this sample app is 1 sec and calls a method that updates the display. Just implement a simmilar timer of duration x minutes and call which ever method you like :)

hhafez
Thank you for the quick reply and the link!
sungl