There is an NSTextField field and you need to make it so that only numbers can be entered into it and that they look like this: "123-456-789"
This problem I solved NSNumberFormatter:
NSString *myString = @"12345678"; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; [formatter setGroupingSeparator:@"-"]; [formatter setGroupingSize:3]; [formatter setMaximumIntegerDigits:9]; NSString *formattedOutput = [formatter stringFromNumber:[NSNumber numberWithInteger:[myString intValue]]]; But the problem is that the formatting takes place not on the right, but on the left, that is, we have:
"12-345-678",
but you need to be so: "123-456-78"