OC Category add property
Asked on 08/05/2024
1 search
To add a property in an Objective-C category, you can use the new entry macro introduced in SwiftUI. This macro provides a convenient syntax for adding new values to SwiftUI keyed storage types, including environment values, focus values, and more.
Here's a brief overview of how you can define a new kind of container value using the entry macro:
- Create an Extension: Start by creating an extension on the container values type.
- Declare a Property: Within the extension, declare a property using the new entry macro. This property can store any value, such as a boolean to track if a card has been rejected.
- Custom View Modifier: Declare a custom view modifier as a convenience for setting your property. This modifier will call through to the new container value API modifier, passing the property's keypath and the new value to set.
- Support in Container: Add support for your new container value within your container. Customize each view depending on the property value.
For more detailed information, you can refer to the session Demystify SwiftUI containers (14:45).
Relevant Sessions
These sessions provide insights into the new entry macro and how to use it effectively in SwiftUI.

Explore object tracking for visionOS
Find out how you can use object tracking to turn real-world objects into virtual anchors in your visionOS app. Learn how you can build spatial experiences with object tracking from start to finish. Find out how to create a reference object using machine learning in Create ML and attach content relative to your target object in Reality Composer Pro, RealityKit or ARKit APIs.

Swift Charts: Vectorized and function plots
The plot thickens! Learn how to render beautiful charts representing math functions and extensive datasets using function and vectorized plots in your app. Whether you’re looking to display functions common in aerodynamics, magnetism, and higher order field theory, or create large interactive heat maps, Swift Charts has you covered.

Run, Break, Inspect: Explore effective debugging in LLDB
Learn how to use LLDB to explore and debug codebases. We’ll show you how to make the most of crashlogs and backtraces, and how to supercharge breakpoints with actions and complex stop conditions. We’ll also explore how the “p” command and the latest features in Swift 6 can enhance your debugging experience.