yoklainterview sim

Mobile Ios Swift Concurrency Structured Interview Questions

75 verified Mobile Ios Swift Concurrency Structured interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Ios Swift Concurrency StructuredDifficulty 1
In GCD (Grand Central Dispatch), what is a DispatchQueue?
  • aA single thread reserved exclusively for that queue's lifetime
  • bAn abstraction that schedules submitted work onto a pool of threads
  • cA compiler directive that disables concurrency checks
  • dA storage container for Swift value types only
Explanation:A DispatchQueue schedules blocks of work (closures) to run on GCD's managed thread pool; it does not own one fixed thread — the system decides which thread actually executes the work.
Ios Swift Concurrency StructuredDifficulty 1
What is the practical difference between queue.sync { ... } and queue.async { ... }?
  • async always runs on the main thread, async never does
  • bsync blocks the calling thread until the block finishes
  • casync blocks the calling thread, sync returns immediately
  • dThere is no observable difference in modern Swift
Explanation:sync waits for the submitted block to complete before returning control to the caller, blocking the calling thread; async submits the block and returns control immediately without waiting.
Ios Swift Concurrency StructuredDifficulty 2
let queue = DispatchQueue(label: "serial")
queue.sync {
    queue.sync {
        print("inner")
    }
}

What happens when this runs?
  • aIt deadlocks: the inner sync waits for the serial queue the outer call already occupies
  • bIt compiles but does nothing at runtime
  • cIt prints "inner" twice
  • dThe compiler rejects nested sync calls
Explanation:A serial queue runs one block at a time. The outer sync occupies the queue and blocks the calling thread waiting for it to finish; the inner sync tries to enqueue and wait on that same occupied serial queue, so neither can proceed — a classic self-deadlock.
Ios Swift Concurrency StructuredDifficulty 1
In Swift's async/await, what does marking a function async mean?
  • aThe function always runs on a background thread
  • bThe function can never throw an error
  • cThe function is automatically retried on failure
  • dThe function may suspend and later resume
Explanation:An async function can suspend at an await point (e.g. waiting on another async operation) and resume later, potentially on a different thread; it does not dictate which specific thread or queue it runs on by itself.
Ios Swift Concurrency StructuredDifficulty 2
What problem does an actor in Swift primarily solve?
  • aIt serializes access to its mutable state
  • bIt makes a type conform to Codable automatically
  • cIt removes the need to ever call await
  • dIt guarantees the type is a value type instead of a reference type
Explanation:An actor protects its mutable state by only allowing one task at a time to execute code that touches that state (actor isolation), which is the language's built-in mechanism against data races on shared mutable state.
Ios Swift Concurrency StructuredDifficulty 2
actor Counter {
    private var value = 0
    func increment() { value += 1 }
    func current() -> Int { value }
}

From outside the actor, how must increment() be called?
  • aawait counter.increment()
  • bcounter.increment() with no await, since actors are synchronous by default
  • cIt cannot be called from outside the actor at all
  • dOnly from a DispatchQueue.main.sync block
Explanation:Calling an actor's method from outside that actor's isolation is a potential suspension point (the call may have to wait its turn), so Swift requires await at the call site even though increment() itself isn't declared async.

Test yourself against the 2400-question Mobile bank.

Start interview