EnvironmentObject

@propertyWrapper
public class EnvironmentObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject

Used to reference and observe environment objects previously set. Environment objects are identified by their type, meaning only one of the same type can exist at a time as an environment object.

Important

Referencing an environment object not previously set will trigger an exception.
  • A wrapper of the underlying ObservableObject that can create Bindings to its properties using dynamic member lookup.

    See more

    Declaration

    Swift

    @dynamicMemberLookup
    public struct Wrapper
  • Declaration

    Swift

    public init()
  • The internal value of this wrapper type.

    Declaration

    Swift

    public var wrappedValue: ObjectType { get set }
  • The direct value of this wrapper, as accessing $foo on a @EnvironmentObject property.

    Declaration

    Swift

    public var projectedValue: EnvironmentObject<ObjectType>.Wrapper { get }