Skip to content

Instantly share code, notes, and snippets.

@satoshin2071
Last active July 29, 2016 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satoshin2071/8398572536f1b6ed7f00698a1a5bd3e4 to your computer and use it in GitHub Desktop.
Save satoshin2071/8398572536f1b6ed7f00698a1a5bd3e4 to your computer and use it in GitHub Desktop.
GCD

Swift3


DispatchQueue.main.async {
}

DispatchQueue.global(attributes: [.qosBackground]).async {
}


DispatchQueue.main.after(when: .now() + 3.0) {
}

Swift2


dispatch_async(dispatch_get_main_queue()) { 
}

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {   
}

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(3.0 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) {
}    

一応ObjC


dispatch_async(dispatch_get_main_queue(), ^{
});

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{    
})

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{	
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment