I'm using this piece of code to limit user input regarding the keyboard.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let allowedCharacters = CharacterSet.init(charactersIn: ".0123456789")
let characterSet = NSCharacterSet(charactersIn: string)
return allowedCharacters.isSuperset(of: characterSet as CharacterSet)
}
but my program crashes when I enter any character.
Update 2: So 99.9% of this solution works great, unfortunately the period/decimal point does not register. Unsure why this is happening?