← All topics/Swift language features

Swift language features interview questions

Scenario-style prompts with sample answer outlines. Focus is on how you would design and reason in real codebases.

  1. 01Value vs reference semantics: struct, class, actorWhen would you choose a struct vs a class vs an actor for a model type in an iOS app? What are the tradeoffs for identity, mutation, and concurrency?
  2. 02Optionals: guard let, if let, chaining, nil coalescingHow do you choose between guard let, if let, optional chaining, and nil coalescing for clarity and safety? When would you avoid force-unwraps?
  3. 03Protocols, generics, and where clausesHow do you use protocol-oriented design with generics and associated types? When do you need a where clause on an extension or generic method?
  4. 04Memory management: ARC, strong, weak, unownedExplain ARC's role in Swift. When do you use weak vs unowned references, and how do you break retain cycles in closures and delegates?
  5. 05Closures: captures and @escapingWhat does @escaping mean for a closure parameter? When can a closure be implicitly non-escaping?
  6. 06Error handling: throws and ResultCompare throws/try/catch with Result for modeling failures.
  7. 07Property wrappers: @State, @Published, custom wrappersWhat problem do property wrappers solve? How would you implement a simple custom property wrapper, and what is the projected value ($)?
  8. 08Copy-on-write in standard library collectionsWhat is copy-on-write for Array and Dictionary? Why does it matter for performance and when does copying still happen?
  9. 09Sendable, ownership, and mutabilityWhat does Sendable communicate to the compiler? How does it relate to actor isolation and mutability in Swift 6 concurrency?