Generic Structure


A property wrapper type for an observable object supplied by a parent or ancestor view.


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


An environment object invalidates the current view whenever the observable object 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(_:) method.


Creating an Environment Object


Creates an environment object.

Getting the Value

var wrappedValue: ObjectType

The underlying value referenced by the environment object.

var projectedValue: EnvironmentObject<ObjectType>.Wrapper

A projection of the environment object that creates bindings to its properties using dynamic member lookup.

struct EnvironmentObject.Wrapper

A wrapper of the underlying environment object that can create bindings to its properties using dynamic member lookup.

Updating the Value

func update()

Updates the underlying value of the environment object.


Conforms To

See Also

Environment Data

struct Environment

A property wrapper type that reads a value from the view’s environment.

struct EnvironmentValues

A collection of environment values propagated through a view hierarchy.