簡體   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