I want to change a binding value to just a normal one. How?
Short answer
- If you are using
Binding<SomeType>
, then usewrappedValue
- If you are using
@Binding
propertyWrapper then using just the variable name should give the value
Long Answer
import SwiftUI
struct Something {
//This is using the Binding propertyWrapper
@Binding var price1: Int
func f1() {
price1 //Int value
$price1 //Binding to the Int
let price2 = $price1 //Type of price2 is Binding<Int>
price2.wrappedValue //Int value
}
}