Post

Replies

Boosts

Views

Activity

Reply to Problem with TextFields and decimals iOS17
I have the exact same issue in my app. I found out that it works with a state variable inside the view. I didn't have any luck binding to a variable inside of an observed object. Hence, my workaround relays the value from a state variable to the observed object. @State private var price: Decimal? func priceTextField() -> some View { let textField = TextField( "Price", value: $price, format: .number ) .keyboardType(.decimalPad) .focused($focusedField, equals: .price) .onAppear { price = model.tx.decimalPrice } if #available(iOS 17.0, *) { return textField.onChange(of: price, initial: false) { model.tx.decimalPrice = price } } return textField }
Oct ’23