Question

I'm using NSNumberFormatter for my NSTextField to make numbers like 1.23 display as +1.23 and -1.23 as -1.23. Everything works fine, until I tried to input directly into the text field.

If I typed in 1.23 and hit return, the form rejected the number by complaining the invalid format. What is wrong here?

I've set the format in IB completely, the the Format(+) field is +0.00, and Format(-) field is -0.00. I've also restricted the Fraction Digits to 2, Positive Prefix to + and Negative Prefix to - respectively.

How can I fix this?

Était-ce utile?

La solution

You can easily do it like this:

enter image description here

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top