Interview guides / ios
SwiftUI Interview Questions (State, Layout, Navigation)
SwiftUI interview questions covering state ownership, layout, navigation, and UIKit bridging with concise example answers.
SwiftUI interviews usually probe state ownership and identity. If you mix up @State, @StateObject, and @ObservedObject, the rest of the conversation gets rocky.
Practice explaining what owns the source of truth and what happens on redraws.
1.What is KVO and what replaced it in many Swift codebases?
KVO observes Obj-C property changes. Prefer Combine, Observation/@Observable, delegates, or closures for Swift-first code. KVO still appears with AVFoundation and legacy APIs.
2.What problem do Coordinators solve?
They own navigation flow so view controllers don’t push/present each other directly—improving reuse and testability of routing. Useful in UIKit; SwiftUI often uses NavigationPath/Router instead.
3.How do you wrap UIKit views in SwiftUI safely?
Implement makeUIView/updateUIView; use Coordinator for delegates. Avoid recreating views unnecessarily; sync state carefully to prevent feedback loops.
4.Compare NavigationStack value-based navigation vs older NavigationView.
NavigationStack uses typed paths/links for deep links and programmatic pops. NavigationView was less flexible and had split-view quirks. Prefer NavigationStack on modern OS versions.
5.How should an app respond to memory warnings?
Drop caches, purge image pipelines, release rebuildable resources, and avoid big allocations. In SwiftUI/UIKit, observe warnings and verify with Memory Graph Debugger.
6.Why annotate UI updates with @MainActor? What happens if you don’t?
UIKit/SwiftUI require main-thread UI access. @MainActor enforces that at compile time with isolation. Skipping it risks crashes/races; use Task { @MainActor in } or MainActor.run for hops.
7.When do you use @State, @Binding, @StateObject, @ObservedObject, and @EnvironmentObject?
@State owns simple local view state. @Binding reads/writes parent-owned state. @StateObject creates and owns an ObservableObject for the view’s lifetime. @ObservedObject observes an object owned elsewhere (don’t create it inline). @EnvironmentObject shares dependencies down the tree. Prefer @Observable (Observation framework) in modern apps where available.
8.What are PreferenceKeys used for?
Child-to-parent communication of layout/geometry data (e.g. measuring views). Useful for sticky headers/custom coordination; overuse can cause extra layout passes.
9.Explain proposed size / child size negotiation in SwiftUI briefly.
Parents propose sizes; children report ideal sizes; modifiers adjust. Frames, stacks, and layout priorities influence outcomes. Misunderstanding leads to unexpected compression/expansion.
Keep going with AceMobileInterview
Reading helps. Timed practice locks it in. Jump into the interactive track for algorithms with LeetCode links, studio projects, debugging zips, and mobile system design.