Browse Questions
  • SPM is Apple's built-in dependency manager for Swift.
  • UITableView reuses cell objects as they scroll off screen rather than creating new ones, keeping memory usage constant regardless of how many rows exist.
  • @MainActor is a global actor that ensures code runs on the main thread.
  • Both manage concurrent work, but async/await (introduced in Swift 5.5) is structured and compiler-checked, while GCD is unstructured and callback-based.

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
}