I created a union between two character sets to be able to use a period with the decimalDigits character set.
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let allowed = CharacterSet.decimalDigits
let period = CharacterSet.init(charactersIn: ".")
let both = CFCharacterSetUnion(allowed as! CFMutableCharacterSet, period as CFCharacterSet)
let characterSet = NSCharacterSet(charactersIn: string)
return both.isSuperset(of: characterSet as CharacterSet)
}
however, returning "both.isSuperset(of: characterSet as CharacterSet)". how to correct?
Update 1:
Errors displayed with the current suggested answer