ConcurrencyMidMCQ

What is the difference between `async/await` and GCD (Grand Central Dispatch)?

Test your knowledge:

Explanation & Code

Answer: Both manage concurrent work, but async/await (introduced in Swift 5.5) is structured and compiler-checked, while GCD is unstructured and callback-based.

async/awaitGCD
StyleStructuredUnstructured
ReadabilityLinear codeNested callbacks
Error handlingthrows / tryManual
CancellationAutomatic (Tasks)Manual
Thread safetyEnforced by actorsManual

Code Example:

// ❌ GCD — nested, harder to read and reason about
func loadUser(completion: @escaping (User?) -> Void) {
    DispatchQueue.global().async {
        let user = fetchFromNetwork()
        DispatchQueue.main.async {
            completion(user)
        }
    }
}

// ✅ async/await — reads like synchronous code
func loadUser() async throws -> User {
    let user = try await fetchFromNetwork()
    return user
}

Rate your understanding:

Ready to practice more Concurrency?

Test yourself with our interactive quiz mode or browse all curated questions for this topic.