objective-ccocoanstextfieldnsformatter

Where can I find NSFormatter example that implements NSTextField masks


In Qt and in C#, I am able to easily define a input mask for things like phone numbers and serial numbers. Everything I have read so far leads me to believe that NSFormatter is the answer, but I am having trouble finding a complete example that does not suck. I really want to create a formatter for serial numbers that uses dashes between the segments and also limits the characters to a-z and 0-9. I want to be able to type over the dashes, copy and paste etc.

Example: ABC12-34DEF-GH567-890IJ-KL123


Solution

  • Although not complete, the best example I’ve found was on CocoaDev: MaskedTextField.

    If you feel like this should be a Cocoa feature, consider filing an enhancement request with Apple.