[Swift]GCD #1

GCD #1

func dispatch_async_main(block: () -> (), delay: Double = 0) {
    if delay <= 0 {
        dispatch_async(dispatch_get_main_queue(), block)
        return
    }
    
    let d = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC)))
    dispatch_after(d, dispatch_get_main_queue()) {
        block()
    }
}