繁体   English   中英

在Swift 2中使用NSTimer.scheduledTimerWithTimeInterval

[英]Using NSTimer.scheduledTimerWithTimeInterval in Swift 2

我需要每X秒调用一个函数[calculatePower(day)],如下所示:

for day = 1...365 {
    calculatePower(day)
}

目前的最佳做法是什么?

您可以这样做(每1/10秒):

NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: #selector(youFuncHere), userInfo: nil, repeats: true)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM