Asynchronous call in Swift
let action = {(i: Int) in
sleep(3)
print(i * 10)
}
let queue = dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)
//Run closure at new thread
dispatch_async(queue) {
action(5)
}
- Log in to post comments