Skip to main content
InterviewHubPRO
Section Overview
Q5

Question 5 of 50

Part 1: SwiftUI Architecture, State & App Lifecycle (1 - 10)

10%
iOS Platform & SwiftUI (50 Qs)•Part 1: SwiftUI Architecture, State & App Lifecycle (1 - 10)

What is the `@Observable` macro in iOS 17+ (Observation Framework)?

senior LevelCode ExampleRxJSLifecycleSystem Design

In Simple Words: Replaces the legacy ObservableObject and @Published property wrappers:

  • Just annotate your class with @Observable.
  • SwiftUI automatically tracks property access down to the specific field level: if a view only reads user.name, changes to user.age will NOT trigger a view re-render!
  • Eliminates @StateObject and @ObservedObject boilerplate entirely.
swift
@Observable
class UserProfile {
    var name = "Alex"
    var score = 100
}