如何在每个“X”中调用函数分钟? [英] How to call function in every "X" minute?
问题描述
我正在尝试制作一个示例iphone应用程序来更新当前位置。
我有一个记录当前位置的函数,logCurrentLocation,但我不知道如何在每X分钟(或几秒)内自动调用此函数。
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).
请告诉我在Apple文档中需要查看哪种方法。
Please advise me which method I need to look at in the apple documentation.
感谢您的帮助。
sung。
推荐答案
查看NSTimer的文档。它允许您安排一个定时器,该定时器将调用一个函数(由您想要调用的Target对象和Selector定义)。您可以更改计时器触发的间隔,它应该可以解决问题!
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!
这篇关于如何在每个“X”中调用函数分钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!