<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ObservedObject",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14ObservedObjectV"
  },
  "title" : "ObservedObject"
}
-->

# ObservedObject

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

```
@MainActor @propertyWrapper @preconcurrency @frozen struct ObservedObject<ObjectType> where ObjectType : ObservableObject
```

## Overview

Add the `@ObservedObject` attribute to a parameter of a SwiftUI [`View`](/documentation/SwiftUI/View)
when the input is an
<doc://com.apple.documentation/documentation/Combine/ObservableObject>
and you want the view to update when the object’s published properties
change. You typically do this to pass a [`StateObject`](/documentation/SwiftUI/StateObject) into a subview.

The following example defines a data model as an observable object,
instantiates the model in a view as a state object, and then passes
the instance to a subview as an observed object:

```
class DataModel: ObservableObject {
    @Published var name = "Some Name"
    @Published var isEnabled = false
}

struct MyView: View {
    @StateObject private var model = DataModel()

    var body: some View {
        Text(model.name)
        MySubView(model: model)
    }
}

struct MySubView: View {
    @ObservedObject var model: DataModel

    var body: some View {
        Toggle("Enabled", isOn: $model.isEnabled)
    }
}
```

When any published property of the observable object changes, SwiftUI
updates any view that depends on the object. Subviews can
also make updates to the model properties, like the [`Toggle`](/documentation/SwiftUI/Toggle) in the
above example, that propagate to other observers throughout the view
hierarchy.

Don’t specify a default or initial value for the observed object. Use the
attribute only for a property that acts as an input for a view, as in the
above example.

> Note: Don’t wrap objects conforming to the
> <doc://com.apple.documentation/documentation/Observation/Observable>
> protocol with `@ObservedObject`. SwiftUI automatically tracks dependencies
> to `Observable` objects used within body and updates dependent views when
> their data changes. Attempting to wrap an `Observable` object with
> `@ObservedObject` may cause a compiler error, because it requires that its
> wrapped object to conform to the
> <doc://com.apple.documentation/documentation/Combine/ObservableObject>
> protocol.
> 
> If the view needs a binding to a property of an `Observable` object in
> its body, wrap the object with the ``doc://com.apple.SwiftUI/documentation/SwiftUI/Bindable`` property wrapper instead;
> for example, `@Bindable var model: DataModel`. For more information, see
> <doc://com.apple.SwiftUI/documentation/SwiftUI/Managing-model-data-in-your-app>.

## Topics

### Creating an observed object

[`init(wrappedValue:)`](/documentation/SwiftUI/ObservedObject/init(wrappedValue:))

Creates an observed object with an initial wrapped value.

[`init(initialValue:)`](/documentation/SwiftUI/ObservedObject/init(initialValue:))

Creates an observed object with an initial value.

### Getting the value

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

The underlying value that the observed object references.

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

A projection of the observed object that creates bindings to its
properties.

[`ObservedObject.Wrapper`](/documentation/SwiftUI/ObservedObject/Wrapper)

A wrapper of the underlying observable object that can create bindings
to its properties.



---

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)