Topic

SwiftUI interview questions

State ownership, view identity, data flow, and compositional UI design for modern Apple platform teams.

Focus areas: State, identity, data flow, and compositional UI design

What is the difference between .task() and .onAppear()?

Both run when a view appears, but .task is async and cancelled with the view’s lifetime, while .onAppear is synchronous and does not cancel work for you

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

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