I'm doing something, which I've done many times. In the delegate method of UITextField textField.shouldChangeText(in: Range, replacementText: String)
, and even though my txtFieldAmount.keyboardType = .decimalPad
I'm checking, if the value of textField can be converted into Float, because I use this type in other functions.
Since iOS 11, the decimal point in the keyboard is replaced with "," which causes the initialization of the Float value to be nil.
Example:
let value = "3.14"
let float = Float(value) //procuces 3.14
let value2 = "3,14"
let float2 = Float(value2) //produces nil
It is a simple currency exchange application in which, I take the value from one textField and set a calculated value in second textField, in format "x.xx"
Any suggestions?