<!--
{
  "documentType" : "article",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Model-data",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Model data"
}
-->

# Model data

Manage the data that your app uses to drive its interface.

## Overview

SwiftUI offers a declarative approach to user interface design. As you compose a
hierarchy of views, you also indicate data dependencies for the views.
When the data changes, either due to an external event or because of an action
that the user performs, SwiftUI automatically updates the affected parts of the
interface. As a result, the framework automatically performs most of the work
that view controllers traditionally do.

![](images/com.apple.SwiftUI/model-data-hero@2x.png)

The framework provides tools, like state variables and bindings, for connecting
your app’s data to the user interface. These tools help you maintain a single
source of truth for every piece of data in your app, in part by reducing the
amount of glue logic you write. Select the tool that best suits the task you
need to perform:

- Manage transient UI state locally within a view by wrapping value types as
  [`State()`](/documentation/SwiftUI/State()) properties.
- Share a reference to a source of truth, like local state, using the
  [`Binding`](/documentation/SwiftUI/Binding) property wrapper.
- Connect to and observe reference model data in views by applying the
  <doc://com.apple.documentation/documentation/Observation/Observable()>
  macro to the model data type. Instantiate an observable model data type
  directly in a view with a [`State()`](/documentation/SwiftUI/State()) property. Share the observable model data
  with other views in the hierarchy without passing a reference using the
  [`Environment`](/documentation/SwiftUI/Environment) property wrapper.

## Topics

### Creating and sharing view state

[Managing user interface state](/documentation/SwiftUI/Managing-User-Interface-State)

Encapsulate view-specific data within your app’s view hierarchy to make your
views reusable.

[`macro State()`](/documentation/SwiftUI/State())

Creates a property that can read and write a value managed by SwiftUI.

[`macro State<Value>(initialValue: Value)`](/documentation/SwiftUI/State(initialValue:))

Creates a property with an initial value that can read and write a value managed by SwiftUI.

[`macro State<Value>(wrappedValue: Value)`](/documentation/SwiftUI/State(wrappedValue:))

Creates a property with a wrapped value that can read and write a value managed by SwiftUI.

[`struct State`](/documentation/SwiftUI/State)

A property wrapper type that can read and write a value managed by SwiftUI.

[`struct Bindable`](/documentation/SwiftUI/Bindable)

A property wrapper type that supports creating bindings to the mutable
properties of observable objects.

[`struct Binding`](/documentation/SwiftUI/Binding)

A property wrapper type that can read and write a value owned by a source of
truth.

### Creating model data

[Managing model data in your app](/documentation/SwiftUI/Managing-model-data-in-your-app)

Create connections between your app’s data model and views.

[Migrating from the Observable Object protocol to the Observable macro](/documentation/SwiftUI/Migrating-from-the-observable-object-protocol-to-the-observable-macro)

Update your existing app to leverage the benefits of Observation in Swift.

  <doc://com.apple.documentation/documentation/Observation/Observable()>

[Monitoring data changes in your app](/documentation/SwiftUI/Monitoring-model-data-changes-in-your-app)

Show changes to data in your app’s user interface by using observable
objects.

[`struct StateObject`](/documentation/SwiftUI/StateObject)

A property wrapper type that instantiates an observable object.

[`struct ObservedObject`](/documentation/SwiftUI/ObservedObject)

A property wrapper type that subscribes to an observable object and
invalidates a view whenever the observable object changes.

  <doc://com.apple.documentation/documentation/Combine/ObservableObject>

### Responding to data changes

[`func onChange(of:initial:_:)`](/documentation/SwiftUI/View/onChange(of:initial:_:))

Adds a modifier for this view that fires an action when a specific
value changes.

[`func onReceive<P>(P, perform: (P.Output) -> Void) -> some View`](/documentation/SwiftUI/View/onReceive(_:perform:))

Adds an action to perform when this view detects data emitted by the
given publisher.

### Distributing model data throughout your app

[`func environmentObject<T>(T) -> some View`](/documentation/SwiftUI/View/environmentObject(_:))

Supplies an observable object to a view’s hierarchy.

[`func environmentObject<T>(T) -> some Scene`](/documentation/SwiftUI/Scene/environmentObject(_:))

Supplies an `ObservableObject` to a view subhierarchy.

[`struct EnvironmentObject`](/documentation/SwiftUI/EnvironmentObject)

A property wrapper type for an observable object that a parent or ancestor
view supplies.

### Managing dynamic data

[`protocol DynamicProperty`](/documentation/SwiftUI/DynamicProperty)

An interface for a stored variable that updates an external property of a
view.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)