what is a @State
Asked on 06/18/2025
1 search
In the context of SwiftUI, @State
is a property wrapper used to declare a source of truth for a view. When you mark a view property with @State
, SwiftUI manages the storage and provides it back for the view to read and write. This allows the view to react to changes in the state, updating the UI accordingly. For example, if you have a view that tracks a rating, you can use @State
to keep track of the current rating and update it over time. SwiftUI will automatically update the view when the state changes, ensuring that the UI reflects the current state of the data.
For more details, you can refer to the session SwiftUI essentials (00:10:41).

Improve memory usage and performance with Swift
Discover ways to improve the performance and memory management of your Swift code. We’ll explore ways to refine your code – from making high-level algorithmic changes to adopting the new InlineArray and Span types for finer control over memory and allocations.

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.

Deploy machine learning and AI models on-device with Core ML
Learn new ways to optimize speed and memory performance when you convert and run machine learning and AI models through Core ML. We’ll cover new options for model representations, performance insights, execution, and model stitching which can be used together to create compelling and private on-device experiences.