Contents

EnvironmentObject

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

Declaration

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

Overview

An environment object invalidates the current view whenever the observable object that conforms to ObservableObject changes. If you declare a property as an environment object, be sure to set a corresponding model object on an ancestor view by calling its environmentObject(_:) modifier.

Topics

Creating an environment object

Getting the value

See Also

Distributing model data throughout your app