NSFormatter allows invalid values

from blog The Desolation of Blog, | ↗ original
I've written before about a caveat with NSFormatter. Now I'm writing about one again. I've discovered what I consider to be a bug in NSFormatter and NSTextField. One of the roles of a formatter is to prevent the user from entering invalid characters into a text field. For example, if you have a text field that is designed to take a number, you might limit entry in the text field to numerical digits. This is accomplished by subclassing NSFormatter and implementing the method isPartialStringValid: proposedSelectedRange: originalString: originalSelectedRange: errorDescription: to return NO when it detects invalid characters. However, I've discovered a situation in which that method returns NO, but the text field still adds an invalid character to its string value.