Tag

Questions tagged “SwiftUI”

Start from this tag, then add more in the filter bar to narrow further. The URL keeps your choices so you can bookmark or share the same view.

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