Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Use the onChange modifier in SwiftUI

Use the onChange modifier in SwiftUI

Daily Coding Tip 028

Type Safely's avatar
Type Safely
Jan 15, 2021
∙ Paid

Share this post

Type Safely
Type Safely
Use the onChange modifier in SwiftUI
Share
Image by GreenvalleyPicture from Pixabay

Here’s a version of yesterday’s tip that uses the onChange modifier instead of a button to add up the values. This allows you to have the two numbers add up automatically when either of them changes. The closure for the modifier gets passed the value it changed to, but since both properties are local we don’t need…

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