In the previous lesson, you learned how to manage local view state using @State and @Binding, focusing on situations where state is confined to individual views. However, as you start developing more complex SwiftUI applications, you’ll often find the need to manage and share state across multiple views that aren’t directly related. This introduces a new challenge: How can you effectively manage shared state in a way that maintains consistency and reactivity across the entire application?
This lesson introduces @Observable, a powerful component of the Observation framework newly introduced in iOS 17. You’ll explore how @Observable enhances state management in SwiftUI by allowing you to manage shared data across different parts of your application. By implementing @Observable, you’ll ensure that changes to shared data are seamlessly and efficiently propagated across all views that depend on that data.
You’ll continue building out the budget-tracking app by implementing @Observable to manage financial entries. This will involve transitioning the data model from a simple struct to a class that conforms to the Observable protocol. You’ll also extend the app’s functionality by adding a totals section that reacts in real time to changes in the financial entries.
Learning Objectives
This lesson will help you to:
Eccubdzahv hmi sefdabc arz xeqqigu en @Ownuzgemlu ik ciqememy nyitix hifi.
Uwqlacicd @Ojnalzincu bqacxev hu lajqji jbiwas mreku odzenl kohfepqo qeujw.
Previous: Quiz: Managing Local View State with @State and @Binding
Next: Intro to Observation in SwiftUI
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.