我正在尝试创建一个简单而整洁的函数,它使用NSTimer为括号中的内容添加延迟。例如,
func Adddelay(delay:Double, closure:()->()) {
//Code in here using NSTimer that will add a delay for as long as stated in delay (the number passed in)
}
从此,我试图通过以下方式使用它:
delay(1){
//Code in here that will execute after a delay of one second
}
功能需要使用NSTimer作为我整体使用它的内容。
非常感谢任何帮助。
答案 0 :(得分:1)
在您的情况下,您需要使用NSTimer的扩展名。发表于要点:https://gist.github.com/dimpiax/e2adc74c25d76d124fc3
<强>更新强>