This is what I've come up with: just set the delegate of the text field, and implement the following method accordingly:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (textField.text.length % 4 == 3) {
if (string.length != 0) {
textField.text = [NSString stringWithFormat:@"%@,%@", textField.text, string];
return NO;
}
}
return YES;
}