# Swift Interview > Questions, detailed answers, topic-based preparation, curated resources, and mock interviews for iOS engineers. Every question page contains a full written answer with Swift code examples. Content is authored in markdown and served as static HTML — no JavaScript is required to read any answer. ## Browse - [iOS interview questions](https://swiftinterview.org/qa): every question, filterable by topic, difficulty, and tag - [Topics](https://swiftinterview.org/topics): questions grouped into study paths - [Tags](https://swiftinterview.org/tags): questions grouped by cross-cutting theme - [Question banks](https://swiftinterview.org/questions): curated paid question sets - [Mentors](https://swiftinterview.org/mentors): book a mock iOS interview, system design, or live coding session - [Sitemap](https://swiftinterview.org/sitemap.xml): complete machine-readable URL list ## Topics - [Swift](https://swiftinterview.org/topics/swift) (13 questions): Core language concepts, ownership, protocols, generics, concurrency, and the details interviewers use to separate memorization from real understanding. - [Concurrency](https://swiftinterview.org/topics/concurrency) (8 questions): Actors, async/await, isolation, Sendable, data races, and the reasoning behind modern Swift concurrency. - [UIKit](https://swiftinterview.org/topics/uikit) (3 questions): View lifecycle, rendering performance, diffable data sources, and the UIKit architecture trade-offs still common in production codebases. - [SwiftUI](https://swiftinterview.org/topics/swiftui) (3 questions): State ownership, view identity, data flow, and compositional UI design for modern Apple platform teams. ## Questions - [What is UIResponder?](https://swiftinterview.org/qa/what-is-uiresponder): Follow a single tap from the button that was pressed up to the app delegate, and use that walk to explain first responder, `nil`-targeted actions, and why hit-testing is a separate step - [How much data can UserDefaults store, and how does it work on disk?](https://swiftinterview.org/qa/userdefaults-storage-limits-and-suites): Explain UserDefaults as a small plist-backed prefs store covering size limits, async disk writes, suiteName vs standard, and why main-thread access is allowed but not free - [How does Swift's Dictionary work under the hood?](https://swiftinterview.org/qa/swift-dictionary-under-the-hood): Walk through Swift Dictionary as a CoW hash table — hashing invariants, collisions, complexity traps, nil removal, ordering, concurrency, and key design for senior interviews - [How does Swift method dispatch work?](https://swiftinterview.org/qa/how-does-swift-method-dispatch-work): Explain Swift's three method-dispatch mechanisms—static, table (vtable and protocol witness tables), and Objective-C message send—and show when `final`, value types, and `@objc dynamic` change which one the compiler uses - [What is the difference between NSCache and Dictionary?](https://swiftinterview.org/qa/nscache-vs-dictionary): Compare Dictionary and NSCache on one concrete example, an image cache for a photo feed, and show where the two diverge on thread safety, automatic eviction, and key and value rules - [What is the difference between let and var in Swift?](https://swiftinterview.org/qa/swift-let-vs-var): Explain that `let` creates an immutable binding while `var` creates a mutable one, then separate how that rule behaves for value types versus reference types - [How do you implement MVVM in SwiftUI?](https://swiftinterview.org/qa/how-do-you-implement-mvvm-in-swiftui): Contrast Combine-era ObservableObject MVVM with iOS 17+ @Observable MVVM, keeping the same Provider → ViewModel → View boundaries, DI, and testability rules - [How would you demonstrate Copy-on-Write behavior with a custom struct?](https://swiftinterview.org/qa/how-would-you-demonstrate-copy-on-write-behavior-with-a-custom-struct): Demonstrate Copy-on-Write with a value-typed linked list that shares storage on assignment and copies it only when a mutation occurs using `isKnownUniquelyReferenced`. - [What concurrency problems should you know in Swift?](https://swiftinterview.org/qa/swift-concurrency-problems): Distinguish race conditions, data races, priority inversion, deadlock, and actor reentrancy anomalies with short Swift examples and practical fixes - [On which thread does Swift call deinit?](https://swiftinterview.org/qa/swift-deinit-mainactor-isolation): Explain that deinit runs where the last strong reference is released, then connect that rule to UI safety, MainActor isolation, and isolated deinit - [How do you make shared mutable state thread-safe in Swift?](https://swiftinterview.org/qa/swift-thread-safe-shared-state): Start with the race condition, then compare locks, semaphores, queues, barriers, and actors for protecting shared mutable state in real Swift code - [What is the UIViewController lifecycle and when is each method called?](https://swiftinterview.org/qa/uikit-viewcontroller-lifecycle): Walk through every important `UIViewController` lifecycle callback, explain its purpose, show the call order with `print(#function)`, and clarify where to put subview setup, constraints, and observation - [What is a closure in Swift?](https://swiftinterview.org/qa/what-is-a-closure-in-swift): A closure is a block of code you can pass and store like a value, and it can capture constants and variables from the surrounding scope - [What's the difference between GCD and OperationQueue?](https://swiftinterview.org/qa/what-s-the-difference-between-gcd-and-operationqueue): GCD is Apple's low-level API for scheduling work on dispatch queues. `OperationQueue` is a higher-level Foundation API that represents work as `Operation` objects with dependencies, cancellation, priorities, and concurrency limits. - [What's the difference between Task, Task.detached, and TaskGroup?](https://swiftinterview.org/qa/what-s-the-difference-between-task-detachedtask-and-taskgroup): `Task` creates unstructured work that inherits context, `Task.detached` creates unstructured work without inheriting context, and a task group creates structured child tasks that the parent awaits together. - [What's the difference between DispatchQueue.main.async and .sync?](https://swiftinterview.org/qa/whats-the-difference-between-dispatchqueue-main-async-and-sync): `.async` schedules work and returns immediately, while `.sync` blocks the caller until the work finishes. On the main queue, `.async` is the normal way to perform UI work, whereas calling `.sync` from the main thread causes a deadlock. - [What's the difference between strong, weak, and unowned references?](https://swiftinterview.org/qa/whats-the-difference-between-strong-weak-and-unowned-references): Under ARC, strong keeps an object alive, unowned tracks a direct non-owning pointer that must outlive use, and weak goes through a side table so access can become nil after deinit - [When would you choose a Swift actor over a serial DispatchQueue?](https://swiftinterview.org/qa/swift-actors-vs-queues): Compare language-level isolation with traditional queue-based synchronization in production iOS code - [What collection types are available in Swift, and when would you use each one?](https://swiftinterview.org/qa/swift-collection-types-complexity): Explain Swift's protocol-driven collection model, then compare Array, Set, Dictionary, and Range by behavior, complexity, hashing, ordering, copy-on-write, and thread-safety tradeoffs - [Which design patterns have you used in iOS, and what tradeoffs did they have?](https://swiftinterview.org/qa/swift-design-patterns-ios-examples): Group design patterns into creational, structural, and behavioral, then explain real iOS examples from SDKs and your own implementation experience with the tradeoffs that matter in production - [What is the difference between print and debugPrint in Swift?](https://swiftinterview.org/qa/swift-print-vs-debugprint): Explain that `print` prefers a user-facing string while `debugPrint` prefers a debug representation, then show when their output is identical and when it diverges - [What is a retain cycle and how do you avoid it?](https://swiftinterview.org/qa/swift-retain-cycle-avoidance): Define retain cycles in ARC terms, show the most common ways teams create them, and explain how to prevent and debug them in production code - [How does struct memory layout work in Swift?](https://swiftinterview.org/qa/swift-struct-memory-layout): Explain `MemoryLayout`, padding, alignment, and stride; show why stored-property order changes a struct's footprint; and connect it to arrays, performance, and low-level interop - [What is the difference between ObservableObject and @Observable in SwiftUI?](https://swiftinterview.org/qa/swiftui-observableobject-vs-observable): Compare Combine-era observation with the iOS 17 Observation system, focusing on invalidation granularity, boilerplate, and how ownership changes in SwiftUI - [How do you decide between @State, @StateObject, @ObservedObject, and @EnvironmentObject?](https://swiftinterview.org/qa/swiftui-state-ownership): StateObject vs ObservedObject comes down to ownership, so map each SwiftUI property wrapper to who owns the object rather than memorizing them in isolation - [How do task groups differ from async let in practical iOS code?](https://swiftinterview.org/qa/task-groups-vs-async-let): Explain when fixed child tasks make `async let` the better tool, and when dynamic fan-out or incremental result handling pushes you to task groups - [What's the difference between frame and bounds in iOS?](https://swiftinterview.org/qa/uikit-frame-vs-bounds): Explain how `frame` and `bounds` describe the same view from two different coordinate systems, then connect that model to layout, transforms, and scrolling