Q/A library

iOS interview questions

Search by title or keywords, narrow by topic, difficulty, or tag, then open a question for a full write-up with code to practice your answer.

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?

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 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?

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

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

On which thread does Swift call deinit?

Explain that deinit runs where the last strong reference is released, then connect that rule to UI safety, MainActor isolation, and isolated deinit

What is the UIViewController lifecycle and when is each method called?

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'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?

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?

.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 collection types are available in Swift, and when would you use each one?

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

What is the difference between ObservableObject and @Observable in SwiftUI?

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?

StateObject vs ObservedObject comes down to ownership, so map each SwiftUI property wrapper to who owns the object rather than memorizing them in isolation

What's the difference between frame and bounds in iOS?

Explain how frame and bounds describe the same view from two different coordinate systems, then connect that model to layout, transforms, and scrolling