如何在每个“X”分钟内调用功能?

时间:2022-12-17 01:08:23

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).

我试图制作一个示例iphone应用程序来更新当前位置。我有一个记录当前位置的函数,“logCurrentLocation”,但我不知道如何在每X分钟(或几秒)内自动调用此函数。

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

请告诉我在Apple文档中需要查看哪种方法。

Thank you for your help.

谢谢您的帮助。

sung.

1 个解决方案

#1


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!

查看NSTimer的文档。它允许您安排一个定时器,该定时器将调用一个函数(由您想要调用的“Target”对象和“Selector”定义)。您可以更改计时器触发的间隔,它应该可以解决问题!

#1


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!

查看NSTimer的文档。它允许您安排一个定时器,该定时器将调用一个函数(由您想要调用的“Target”对象和“Selector”定义)。您可以更改计时器触发的间隔,它应该可以解决问题!