swift playgroundでNSTimerを使う方法を記載
playgroundの実行はそのままだと終了してしまうので、
XCPlaygroundPage.currentPage.needsIndefiniteExecutionをtrueに設定して永続するようにします。
import UIKit
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
class timerController:NSTimer {
func setTimer() {
let _fps = round(1000/30)*0.001;
NSTimer.scheduledTimerWithTimeInterval(_fps, target: self, selector: Selector("ticker"), userInfo: nil, repeats: true)
}
func ticker() {
print("hoge")
}
}
var obj:timerController = timerController();
obj.setTimer()
以上