2015-04-01 53 views
0

我想創建一個簡單而整潔的函數,它使用NSTimer爲括號中的內容添加延遲。對於例如使用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什麼我使用它作爲一個整體。

任何幫助將不勝感激。

+1

有什麼錯http://stackoverflow.com/a/29338910/1187415? – 2015-04-01 05:05:56

+0

它確實工作正常,但我瞭解NSTimer並知道如何將它用於我需要的功能,我只需要幫助將它變成簡單功能以便於使用。 – JohnnyCash 2015-04-01 05:57:46

回答