Skip navigation.
 
ml"final" string validation in custom NSFormatter
FROM : Mark Dawson
DATE : Fri Dec 10 19:48:28 2004

When writing a custom formatter, how do I do a "final" string
validation?  I've overriden "isPartialStringValid", which works fine,
up to a point.

In my case, I allow fractions.  So the user typing in "1/" is valid to
that point.  However, if they try to commit that (pressing the enter
key, tabbing, exiting out, etc) the string is now INVALID (i.e., you
need a denominator).

I assume there should be some test in getObjectValue for "exit key",
returning an error (not allowing the user to exit) if the final keys
are not valid, and a similar test in stringForObjectValue that would
not cause a reformat until the text field was committed & validated
(i.e., I might allow fractional input, but want only decimal output,
1/2 --> 0.5).

Thanks for any insight!

mark
<email_removed>

Related mailsAuthorDate
ml"final" string validation in custom NSFormatter Mark Dawson Dec 10, 19:48
mlRe: "final" string validation in custom NSFormatter Louis C. Sacha Dec 12, 10:51