© Bear Cahill 2021
B. CahillUI Design for iOS App Developmenthttps://doi.org/10.1007/978-1-4842-6449-2_4

4. Binding Source of Truth

Bear Cahill1  
(1)
Denton, TX, USA
 

We introduced @State in the previous chapter. We’ll revisit that briefly here as well as discuss more concepts of the flow of data in SwiftUI.

Data Drives the UI

Typically , in app development, the UI represents the data and state. When the user taps a button or flips a switch, the event drives a method call. In that method, we typically have code that updates the current data.

In the last chapter, we looked at how we used @State to specify the source of truth for the toggle switch. By binding the isReady boolean variable to the toggle, we saw that toggling the switch updated the value. ...

Get UI Design for iOS App Development: Using SwiftUI 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.