Daily iOS
SwiftUI

Observation framework

In SwiftUI, what does the iOS 17 @Observable macro give you over the older ObservableObject plus @Published approach? Ground it in how the two work internally.

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

@Observable tracks property access, so the unit of update is fine-grained: only the properties body actually uses, and only the views that need them redraw; it works without Combine, and passing nested objects, optionals, and collections is natural. With ObservableObject, one objectWillChange updates every subscribed view.

Share a question