To add an argument to the delay function.
Install the dictionary first, then add it as userInfo. Untie the information with a timer as an argument.
let arg : Int = 42 let infoDict : [String : AnyObject] = ["argumentInt", arg] NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(3), target: self, selector: "functionHereWithArgument:", userInfo: infoDict, repeats: false)
Then in the called function
func functionHereWithArgument (timer : NSTimer) { if let userInfo = timer.userInfo as? Dictionary<String, AnyObject> { let argumentInt : Int = (userInfo[argumentInt] as! Int) } }
KorinW Feb 23 '16 at 0:32 2016-02-23 00:32
source share