2016-12-13 86 views
0

你好我試圖執行這條線在操場上的代碼,但得到response.My代碼的任何輸出如下:回調中迅速3遊樂場

func testCallbackEmpty(callback: @escaping () -> Void) { 

     DispatchQueue.main.asyncAfter(deadline: .now() + 5) { 
      callback() 
     } 
    } 

    testCallbackEmpty(callback: {() -> Void in 
     print("Hey called here") 
    }) 


enum Result { 
    case OK, FAILED 
} 


func mainCallback(callback: @escaping (Result) -> Void) { 
    DispatchQueue.main.asyncAfter(deadline: .now() + 5) { 
     callback(Result.OK) 
    } 

} 

mainCallback(callback: { result in 
    print("Hurray \(result)") 
}) 
+0

嗨JPetric我解決了這個謝謝。 – sector11

回答

2

我不得不寫

import UIKit 

import PlaygroundSupport 
PlaygroundPage.current.needsIndefiniteExecution = true 

位於文件頂部

解決了。