How to call function in every “X” minute?

2019-02-20 18:03发布

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条回答
别忘想泡老子
2楼-- · 2019-02-20 18:09

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!

查看更多
登录 后发表回答