在Swift 2中,我能够dispatch_after使用大中央调度来延迟一个动作:
var dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue(), {
// your function here
})
Run Code Online (Sandbox Code Playgroud)
但这似乎不再在Swift 3(或4)中编译.在Swift 3中使用新的Dispatch API编写它的首选方法是什么?