@Observable code exampe
Asked on 2025-08-01
1 search
It seems like you're interested in observable code examples. At WWDC, Apple introduced several features related to observables across different sessions. Here are some highlights:
-
UIKit and Observables: In the session "What’s new in UIKit," automatic observation tracking was discussed. UIKit now supports observable model objects, which can automatically track dependencies and update UI components like labels and collection view cells when the underlying data changes. This feature reduces the need for extra code to keep the UI in sync with data changes. You can learn more about this in the chapter on Automatic observation tracking.
-
SwiftUI and Observables: In the session "Optimize SwiftUI performance with Instruments," the use of observables in SwiftUI was explored. The session highlighted how to optimize performance by creating more granular data dependencies, which helps in reducing unnecessary view updates. This is particularly useful when dealing with collections or lists where only specific items change. More details can be found in the chapter on Understand causes and effects of SwiftUI updates.
-
Swift and Observables: The session "What’s new in Swift" introduced the Observation Library, which provides APIs for tracking state changes in an object graph. This allows developers to stream state changes using an async sequence from an observable type, making it easier to react to changes in data. This is covered in the chapter on Libraries: Observation.
These sessions provide a comprehensive overview of how observables are being integrated into Apple's frameworks to enhance app performance and simplify state management.

What’s new in UIKit
Modernize your app with the latest APIs in UIKit, including enhanced menu bar support, automatic observation tracking, a new UI update method, and improvements to animations. We’ll also cover how you can include SwiftUI scenes in your UIKit app and explore SF Symbols, HDR color pickers, and more.

Optimize SwiftUI performance with Instruments
Discover the new SwiftUI instrument. We’ll cover how SwiftUI updates views, how changes in your app’s data affect those updates, and how the new instrument helps you visualize those causes and effects. To get the most out of this session, we recommend being familiar with writing apps in SwiftUI.

Better together: SwiftUI and RealityKit
Discover how to seamlessly blend SwiftUI and RealityKit in visionOS 26. We’ll explore enhancements to Model3D, including animation and ConfigurationCatalog support, and demonstrate smooth transitions to RealityView. You’ll learn how to leverage SwiftUI animations to drive RealityKit component changes, implement interactive manipulation, use new SwiftUI components for richer interactions, and observe RealityKit changes from your SwiftUI code. We’ll also cover how to use unified coordinate conversion for cross-framework coordinate transformations.