I want to change a binding value to just a normal one. How?
Binding issue
Add a Comment
I want to change a binding value to just a normal one. How?
Short answer
Binding<SomeType>, then use wrappedValue@Binding propertyWrapper then using just the variable name should give the valueLong 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
}
}
Short answer
Binding<SomeType>, then use wrappedValue@Binding propertyWrapper then using just the variable name should give the valueLong 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
}
}