Type Safely

Share this post
Using The .focusedValue Modifier and @FocusedBinding Property Wrapper In SwiftUI
typesafely.substack.com

Using The .focusedValue Modifier and @FocusedBinding Property Wrapper In SwiftUI

Daily Coding Tip 041

Type Safely
Feb 3, 2021
Share this post
Using The .focusedValue Modifier and @FocusedBinding Property Wrapper In SwiftUI
typesafely.substack.com
Image by Myo Min Kyaw from Pixabay

This is a new way to pass data between Views. Instead of having an ObservableObject, we save data using a FocusedValueKey.

In the following example, DisplayTextView is able to show the text you type into TextFieldView, despite the fact that a Binding<String> or String constant is not passed between the Views.

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2022 Type Safely
Privacy ∙ Terms ∙ Collection notice
Publish on Substack Get the app
Substack is the home for great writing