The SwiftUI Environment

November 20, 2022

Types as Keys

In SwiftUI, the environment allows setting and getting values where the keys are types conforming to a protocol and have default values. Here’s a sketch of what the implementation might look like: