Limit UITextField to one decimal point Swift
How can I limit a UITextField to one decimal point with Swift? The text field is for entering a price, so I cannot allow more than one decimal point. If I was using Objective-C, I would have used this code: -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string]; NSArray *sep = [newString componentsSeparatedByString:@"."]; if([sep count] >= 2) { NSString *sepStr=[NSString stringWithFormat:@"%@",[sep objectAtIndex:1]]; return !(