Chapter 8

Understanding State Management in SwiftUI

IN THIS CHAPTER

check Understanding how a property wrapper works

check Working with state variables

check Binding state variables

check Managing state from external objects

check Sharing objects

check Accessing built-in environment variables

If you’ve read this book from the beginning and arrived at this chapter, you should have a good understanding of how SwiftUI works. SwiftUI builds your user interface (UI) declaratively, and it relies heavily on the concept of state variables to keep its UI updated. Besides @State, there are a number of other mechanisms for state management in SwiftUI. These mechanisms are the focus of this chapter.

Using a Property Wrapper

SwiftUI 5.1 introduced a new feature to the language: the property wrapper. A property wrapper is a generic data structure that has read/write capabilities, while at the same time providing and enforcing additional ...

Get SwiftUI For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.