Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get value change update on Binding in SwiftUI

I have a binding on my SwiftUI view

@Binding var pinValue: String

I want to get update every time the value is changed. I tried below as I’d do on a publisher but I’m getting errors because it’s not a publisher.

.onReceive($pinValue, perform: { output in
            print(output)
        })

I’ve also tried to access $pinValue.publisher but the .onReceive block wont’ work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How can I get an update every time the value of pinValue is changed?

>Solution :

Use instead

.onChange(of: pinValue) { output in
  print(output)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading