Introduction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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:

See forum comments
Download course materials from Github
Previous: Quiz: Managing Local View State with @State and @Binding Next: Intro to Observation in SwiftUI