Creating a concurrent queue in swift

Creating a concurrent queue
let concurrentQueue = DispatchQueue(label: "queuename", attributes: .concurrent)
concurrentQueue.sync {

}  
Create a serial queue
let serialQueue = DispatchQueue(label: "queuename")
serialQueue.sync { 

}
Get main queue asynchronously
DispatchQueue.main.async {

}
Get main queue synchronously
DispatchQueue.main.sync {

}
To get one of the background thread
DispatchQueue.global(qos: .background).async {

}
Xcode 8.2 beta 2:
To get one of the background thread
DispatchQueue.global(qos: .default).async {

}

DispatchQueue.global().async {
    // qos' default value is ´DispatchQoS.QoSClass.default`
}
DispatchQueue.global(qos: .background).async {
    // Background Thread
    DispatchQueue.main.async {
        // Run UI Updates or call completion block
    }
}
If you want to learn about using these queues .See this answer

Comments

Most popular posts

Implementing a Custom Back Button in Swift

The Android Kotlin style guides

SQL injection in Android content providers and how to be protected

Chronometer Tutorial With Example In Android Studio

How to clear all activity stack in Android

Exploring Background Execution Limits on Android Oreo

WKWebView advanced tutorial (catch JS events, access properties etc...) (Swift)

Using Realm Mobile Database with Swift 4.0 (Insert, Update, Delete, List)

How to adjust image content mode using aspect fill, aspect fit and scaling

From Swift to Javascript and Back