Interview Cheat Sheet
Top 50 Q&A from across the book, condensed for the night before your interview. If you can answer all 50 cleanly, you’re ready.
Swift language
1. Class vs struct? Struct is a value type — copied on assignment, lives on the stack typically. Class is a reference type — shared via reference, lives on the heap. Default to struct unless you need identity, inheritance, or shared mutable state.
2. What’s a Swift actor?
A reference type with serialized access to its mutable state. Methods are implicitly async from outside. Use to protect mutable state from data races without manual locking.
3. Sendable?
A protocol marking a type as safe to pass across concurrency domains. Value types of Sendable components are auto-Sendable. Classes need to be final and either immutable or @unchecked Sendable with manual synchronization.
4. async/await vs Combine?
async/await is the modern path for one-shot async work. Combine is event streams over time (publishers). For new code, prefer async/await; reach for AsyncSequence if you need event streams.
5. weak vs unowned?
Both avoid retain cycles. weak is optional and becomes nil when the referent deallocates. unowned is non-optional and crashes if accessed after the referent is gone. Use weak unless you can prove the lifetime relationship guarantees safety.
6. Optional internals?
It’s an enum: case none and case some(Wrapped). ?. is sugar for pattern matching the .some case. ! force-unwraps and crashes on .none.
7. protocol with associated type?
Defines a generic placeholder the conforming type provides. Can’t be used directly as a variable type (existential limitations) — need any or generic constraints.
8. @escaping closure?
A closure that can outlive the function it was passed into. Required for callbacks stored or dispatched asynchronously. Implies you need to manage references carefully (cycles).
9. Result builders?
@resultBuilder lets a type aggregate sub-expressions into a single value. SwiftUI’s ViewBuilder is one. Foundation for DSLs like SwiftUI views, regex builder, etc.
10. Macros (Swift 5.9+)?
Compile-time code generation. @attached macros modify types/properties (e.g., @Observable, @Model). #freestanding macros expand to code (e.g., #Preview). Run as Swift programs at compile time.
SwiftUI
11. View identity?
SwiftUI uses the View’s structural position + explicit id to track identity across redraws. Identity changes cause state reset; same identity preserves state. id(...) modifier overrides.
12. @State vs @StateObject vs @Observable?
@State for value-type local state. @StateObject for reference-type owned by the view. @Observable (Swift 5.9+) is the modern replacement for ObservableObject — no more @Published, just @Observable macro on the class and @Bindable/@State in the view.
13. @Binding?
A two-way reference to state owned elsewhere. Passes write-back to parent. Use for child views that mutate parent state.
14. View lifecycle?
.onAppear, .task, .onDisappear. .task is async-aware and auto-cancels when the view disappears. Prefer .task over .onAppear for async work.
15. NavigationStack vs NavigationView?
NavigationStack (iOS 16+) is the modern API with proper programmatic navigation via a path binding. NavigationView is deprecated.
Concurrency
16. What is a Task?
A unit of asynchronous work. Created via Task { ... } or implicit in .task modifier. Has its own cancellation and priority.
17. Structured concurrency?
async let and TaskGroup — child tasks tied to parent’s lifetime. Cancellation propagates. Errors propagate. Easier to reason about than free Task {}.
18. @MainActor?
An actor pinned to the main thread. Mark types or methods to force main-thread execution. SwiftUI views are implicitly @MainActor.
19. Data race in Swift 6?
Compile error. Swift 6 enforces data race safety. Cross-actor mutable state without Sendable won’t compile.
20. Task.detached?
A task not inheriting parent’s actor, priority, or cancellation. Use sparingly — usually a code smell. Normal Task {} is almost always what you want.
Memory & performance
21. Retain cycle in a closure?
A closure that captures self strongly, stored on self. Break via [weak self] or [unowned self] capture.
22. ARC?
Automatic Reference Counting. Compiler inserts retain/release calls. Cycles aren’t broken automatically — you need weak/unowned.
23. Profiling an app? Instruments. Time Profiler for CPU, Allocations for memory, Leaks for cycles, SwiftUI instrument for view-body churn.
24. lazy property?
Computed on first access, stored after. Cannot be on a struct stored property that needs mutation without mutating. Use for expensive one-time initialization.
Data
25. Core Data vs SwiftData?
SwiftData is the modern Swift-native wrapper around Core Data. Uses @Model macro. Same engine, friendlier API. New apps targeting iOS 17+ use SwiftData; older apps stay on Core Data.
26. CloudKit private DB vs public DB? Private DB: one per user, syncs to that user’s iCloud, only they read/write. Public DB: app-wide, all users see, app developer controls schema.
27. CKShare? Lets a user share a record (or zone) with other iCloud users. Requires recipients to be on iCloud.
28. Codable?
Protocol combining Encodable and Decodable. Free implementation for types whose properties are all Codable. Customize via CodingKeys.
29. JSON parsing?
JSONDecoder().decode(MyType.self, from: data). Handle missing fields with optional properties. Use keyDecodingStrategy = .convertFromSnakeCase for API conventions.
Architecture
30. MVC vs MVVM vs MV (SwiftUI)? MVC: classic UIKit pattern, controller mediates. MVVM: ViewModel exposes formatted state, view binds. MV (SwiftUI): model + view directly; SwiftUI’s reactivity makes the ViewModel often redundant. Use what fits — don’t impose MVVM everywhere.
31. Dependency injection? Pass dependencies as init parameters or via environment. Avoid global singletons; they kill testability.
32. The Composable Architecture? Point-Free’s redux-style framework. State + Action + Reducer + Effects. Deterministic, testable, more boilerplate. Worth it for complex state trees.
33. Module boundaries? Use SwiftPM packages to split features. Core / shared utilities at the bottom, feature modules above, app at top. Hide implementation; expose protocols.
Testing
34. Unit vs UI vs integration test? Unit: pure logic, fast, isolated. UI: drives the actual app, slow, brittle. Integration: multiple components together but no real network/DB. Pyramid: lots of units, fewer integrations, very few UI tests.
35. Mocking dependencies? Define a protocol. Production class implements it. Mock class implements it for tests. Inject via init.
36. XCTest vs Swift Testing?
Swift Testing (@Test, #expect) is the new framework added in Swift 6 era. More expressive, parallelism-first, native to Swift. XCTest still works; use it for existing code and ObjC interop.
37. Snapshot tests? Render UI to an image and compare against baseline. Catches visual regressions. Pair with normal logic tests.
Networking
38. URLSession basics?
URLSession.shared.data(for: request) returns (Data, URLResponse). Use async/await. Custom session for caching, timeout, headers.
39. HTTPS / TLS? ATS (App Transport Security) enforces HTTPS by default since iOS 9. Override only with justification.
40. Retry strategy? Exponential backoff with jitter. Cap retries (3-5). Don’t retry on 4xx (client error). Retry on 5xx and network errors.
Security
41. Keychain vs UserDefaults? Keychain for secrets (tokens, passwords, keys) — encrypted, survives uninstall optionally, hardware-backed. UserDefaults for plain preferences — plaintext, not for secrets.
42. Sign in with Apple? Privacy-first authentication. Returns a stable user ID. Apple may give a hidden email relay. Required if you offer third-party social login.
43. Code obfuscation? Limited value on iOS — App Store binaries are already protected. Don’t waste budget on obfuscation.
Apple ecosystem
44. WidgetKit? Extension-based widgets on home screen + lock screen. SwiftUI views with a TimelineProvider supplying entries. No interactivity beyond AppIntent buttons (iOS 17+).
45. AppIntents? Define actions Shortcuts and Siri can invoke. SwiftUI-like declarative API. Replaces older SiriKit / Intents framework.
46. Live Activities? A persistent piece of UI on lock screen + Dynamic Island. ActivityKit. Limited duration. Updates via push or in-app.
47. WatchKit / watchOS apps? Independent SwiftUI app on the watch. Communicates with phone via WatchConnectivity. Complications for the watch face.
Deployment
48. Code signing? Each binary signed with your developer certificate, embedded in a provisioning profile listing the entitlements and devices/distribution rules. Xcode handles most via “Automatically manage signing.”
49. TestFlight? Apple’s beta testing. Internal testers (your team, no review) and external (up to 10,000, requires App Review of the build). Builds live 90 days.
50. App Store Review common rejections? Vague privacy policy, missing usage description strings, crashes on launch, third-party login without Sign in with Apple, IAP outside Apple’s IAP system, misleading screenshots.
The night-before drill
Read these 50, then do the PlanBoard talking points drill out loud — the full 30-second pitch + 3-minute deep dive of your strongest capstone. Then sleep.