---
title: Observation
framework: Observation
role: collection
role_heading: Framework
platforms: [iOS 17.0+, iPadOS 17.0+, Mac Catalyst 17.0+, macOS 14.0+, tvOS 17.0+, visionOS 1.0+, watchOS 10.0+]
path: observation
---

# Observation

Make responsive apps that update the presentation when underlying data changes.

## Overview

Overview Observation provides a robust, type-safe, and performant implementation of the observer design pattern in Swift. This pattern allows an observable object to maintain a list of observers and notify them of specific or general state changes. This has the advantages of not directly coupling objects together and allowing implicit distribution of updates across potential multiple observers. The Observation frameworks provides the following capabilities: Marking a type as observable Tracking changes within an instance of an observable type Observing and utilizing those changes elsewhere, such as in an app’s user interface To declare a type as observable, attach the Observable() macro to the type declaration. This macro declares and implements conformance to the Observable protocol to the type at compile time. @Observable class Car {     var name: String = ""     var needsRepairs: Bool = false          init(name: String, needsRepairs: Bool = false) {         self.name = name         self.needsRepairs = needsRepairs     } } To track changes, use the withObservationTracking(_:onChange:) function. For example, in the following code, the function calls the onChange closure when a car’s name changes. However, it doesn’t call the closure when a car’s needsRepair flag changes. That’s because the function only tracks properties read in its apply closure, and the closure doesn’t read the needsRepair property. func render() {     withObservationTracking {         for car in cars {             print(car.name)         }     } onChange: {         print("Schedule renderer.")     } }

## Topics

### Observable conformance

- [Observable()](observation/observable().md)
- [Observable](observation/observable.md)

### Change tracking

- [withObservationTracking(_:onChange:)](observation/withobservationtracking(_:onchange:).md)
- [ObservationRegistrar](observation/observationregistrar.md)

### Observation in SwiftUI

- [Managing model data in your app](swiftui/managing-model-data-in-your-app.md)
- [Migrating from the Observable Object protocol to the Observable macro](swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro.md)

### Structures

- [ObservationTracking](observation/observationtracking.md)
- [Observations](observation/observations.md)

### Functions

- [withContinuousObservation(options:apply:)](observation/withcontinuousobservation(options:apply:).md)
- [withObservationTracking(options:_:onChange:)](observation/withobservationtracking(options:_:onchange:).md)

### Macros

- [ObservationIgnored()](observation/observationignored().md)
- [ObservationTracked()](observation/observationtracked().md)
