Adding custom keys to the SwiftUI environment
www.donnywals.comSometimes you’ll find yourself in a situation where you want to conveniently pass some object down via the SwiftUI environment. An easy way to do this is through the .environmentObject
view modifier. The one downside of this view modifier and corresponding @EnvironmentObject
property wrapper is that the object you add to the environment must be an observable object.