grand central dispatch - How does DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) work in Swift 3? -


in swift 3 syntax of gcd has changed quite bit.

a call dispatch_after() looks this:

dispatchqueue.main.asyncafter(deadline: .now() + 5.0) {//do something} 

that code invoke block 5 seconds after it's called.

how work? docs deadline parameter dispatch_time_t, typealias uint64. assume it's mach time in nanoseconds. however, .now() + delay syntax adding decimal seconds value. doesn't dispatchtime.now() return uint64 ? if so, adding decimal seconds should not work. if anything, expect value added .now() treated nanoseconds, not useful.

(in swift 2 used have multiply value constant number of nanoseconds per second.)

ok, found answer own question in thread:

how write dispatch_after gcd in swift 3?

apparently there override of + operator takes dispatchtime , double, treats double decimal seconds, , returns resulting dispatchtime.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -