property wrapper
Asked on 08/04/2024
1 search
Property wrappers in Swift are a powerful feature that encapsulate logic for managing stored values. They allow you to intercept calls to read and write a property, implementing reusable logic that can be applied with a simple annotation. This can help in creating type-safe APIs and eliminating boilerplate code in your applications.
For example, in the session A Swift Tour: Explore Swift’s features and design, property wrappers are demonstrated using the argument
property wrapper from the Swift ArgumentParser package. This wrapper designates that a property stores the value of a command line argument.
Additionally, in the session What’s new in Xcode 16, the previewable
macro is introduced, which can be attached to property wrappers like state
, allowing them to be used directly within a preview block, thus simplifying the process of writing wrapper views.
For more detailed information, you can refer to the following sessions:
Relevant Sessions
- A Swift Tour: Explore Swift’s features and design
- What’s new in Xcode 16

SwiftUI essentials
Join us on a tour of SwiftUI, Apple’s declarative user interface framework. Learn essential concepts for building apps in SwiftUI, like views, state variables, and layout. Discover the breadth of APIs for building fully featured experiences and crafting unique custom components. Whether you’re brand new to SwiftUI or an experienced developer, you’ll learn how to take advantage of what SwiftUI has to offer when building great apps.

What’s new in Xcode 16
Discover the latest productivity and performance improvements in Xcode 16. Learn about enhancements to code completion, diagnostics, and Xcode Previews. Find out more about updates in builds and explore improvements in debugging and Instruments.

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.