@Environment

Asked on 03/05/2025

1 search

The @Environment property wrapper in SwiftUI is used to read values from the environment. It allows you to access shared data or actions that are available throughout the SwiftUI view hierarchy. For example, in the session Work with windows in SwiftUI, an environment property is used to retrieve an open window action by creating an environment property with a keypath of open window. This allows you to perform actions like opening or closing windows within your SwiftUI app.

If you have more specific questions about how @Environment is used in SwiftUI or need further details, feel free to ask!

@Environment | Ask WWDC