Type Safely

Type Safely

Use the onChange modifier in SwiftUI

Daily Coding Tip 028

Type Safely's avatar
Type Safely
Jan 15, 2021
∙ Paid
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…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture