How does the new @Entry macro work?
Asked on 2024-07-17
1 search
The new @Entry macro in SwiftUI simplifies the process of adding new values to SwiftUI's keyed storage types, such as environment values, focus values, and the new container values. Instead of writing a full conformance to EnvironmentKey and an extension on EnvironmentValues, you can now use the @Entry macro to declare a property directly. This macro provides a convenient syntax for adding these values, making it easier to work with SwiftUI.
For example, you can use the @Entry macro to create a new container value by declaring a property within an extension on the ContainerValues type. This property can then be used to store and track specific values, such as a boolean to indicate if a card has been rejected. Additionally, you can create custom view modifiers to set these properties, enhancing the customization capabilities of your SwiftUI containers.
To learn more about the @Entry macro and its applications, you can refer to the session Demystify SwiftUI containers (14:45).

What’s new in SwiftData
SwiftData makes it easy to add persistence to your app with its expressive, declarative API. Learn about refinements to SwiftData, including compound uniqueness constraints, faster queries with #Index, queries in Xcode previews, and rich predicate expressions. Join us to explore how you can use all of these features to express richer models and improve performance in your app. To discover how to build a custom data store or use the history API in SwiftData, watch “Create a custom data store with SwiftData” and “Track model changes with SwiftData history”.

Demystify SwiftUI containers
Learn about the capabilities of SwiftUI container views and build a mental model for how subviews are managed by their containers. Leverage new APIs to build your own custom containers, create modifiers to customize container content, and give your containers that extra polish that helps your apps stand out.

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.
