NSTimer のユーザー情報を使用して UIButton を渡そうとしています。NSTimers の stackoverflow に関するすべての投稿を読みました。かなり近づいているのですが、なかなかたどり着けません。この投稿は役に立ちました
func timeToRun(ButonToEnable:UIButton) {
var tempButton = ButonToEnable
timer = NSTimer.scheduledTimerWithTimeInterval(4, target: self, selector: Selector("setRotateToFalse"), userInfo: ["theButton" :tempButton], repeats: false)
}
タイマーが実行する関数
func setRotateToFalse() {
println( timer.userInfo )// just see whats happening
rotate = false
let userInfo = timer.userInfo as Dictionary<String, AnyObject>
var tempbutton:UIButton = (userInfo["theButton"] as UIButton)
tempbutton.enabled = true
timer.invalidate()
}