How to restrict textfield to accept only decimal values in swift
问题 I want to accept only decimal values in my textfield. The following code allows me to enter only numbers and '.' but we can enter more than one '.' How can i restrict it to just one '.' or how can I restrict the textfield to accept only decimal values in swift 3.1 let aSet = NSCharacterSet(charactersIn:"0123456789.").inverted let compSepByCharInSet = r_Qty_txt.text?.components(separatedBy: aSet) let numberFiltered = compSepByCharInSet?.joined(separator: "") My target device is iPad.