Type Safely

Type Safely

Share this post

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

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

Daily Coding Tip 041

Type Safely's avatar
Type Safely
Feb 03, 2021
∙ Paid

Share this post

Type Safely
Type Safely
Using The .focusedValue Modifier and @FocusedBinding Property Wrapper In SwiftUI
Share
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.

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share