Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_26918391/article/details/76570615
-
1. The most common template GCD
Global asynchronous execution queue
DispatchQueue.global().async { //耗时操作写在这里 DispatchQueue.main.async { //回到主线刷新 } }
DispatchQueue.global().async { //耗时操作写在这里 DispatchQueue.main.sync { //回到主线刷新 } }
-
2. delay call
let delay:TimeInterval = 3 DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delay) { //3秒后在主线程执行 }