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

6. Environment Values

Bear Cahill1  
(1)
Denton, TX, USA
 

So far, we’ve seen how to use the State property wrapper for values within a given view. We’ve also seen how to bind local values to external variables with Binding.

In both of those cases, our code needs to create and control the values. These values, via property wrappers, are then passed around. Using property wrappers in this way keeps the source of truth both isolated and always in sync.

But what about values that might be created somewhere else? What about values that might affect the whole app or device?

SwiftUI has solutions for that as well with Environment values and objects.

Environment ...

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.