Sto provando a passare un UIButton con un userinfo di NSTimer. Ho letto ogni post su StackOverflow su NSTimers. Mi sto avvicinando molto ma non riesco a raggiungerlo. Questo post ha aiutatorapido NSTimer userinfo
func timeToRun(ButonToEnable:UIButton) {
var tempButton = ButonToEnable
timer = NSTimer.scheduledTimerWithTimeInterval(4, target: self, selector: Selector("setRotateToFalse"), userInfo: ["theButton" :tempButton], repeats: false)
}
la funzione che il timer si
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()
}
Ciao, grazie che è molto utile – user2164327
Nessun problema. Potresti segnare una risposta quando hai un momento. Cheers –
Inoltre, non devi assolutamente passare un dizionario come 'userInfo', hai solo bisogno di un oggetto conforme a' AnyObject? '. Personalmente, l'ho usato per passare un 'String' – tfrank377