do we no longer need @environmentobject and other property wrappers? are @environment, @state and @bindable enough?

Asked on 08/02/2024

1 search

The property wrappers @environmentObject, @state, and @binding are still relevant and necessary in SwiftUI. The new improvements and features introduced at WWDC 2024, such as the entry macro, make it easier to work with environment values and other state management tools, but they do not replace the existing property wrappers.

For example, the entry macro simplifies the process of conforming to EnvironmentKey and extending EnvironmentValues, but it does not eliminate the need for @environmentObject or other property wrappers. These wrappers are fundamental to managing state and dependencies in SwiftUI.

To learn more about these improvements, you can check out the session What’s new in SwiftUI (13:25).

Relevant Sessions

  1. What’s new in SwiftUI
  2. A Swift Tour: Explore Swift’s features and design
  3. What’s new in Xcode 16
  4. SwiftUI essentials
  5. Enhance your UI animations and transitions