I want to insert a number into a Text Field.
If the is larger then 0.001 the number should be displayed as 1.234 (0.000). If the is smaller then 0.001 the number should be displayed as 1.234E-5 (0.000E+0).
I had a look in "LOCALE DATA MARKUP LANGUAGE (LDML)" using Choice Pat开发者_开发技巧terns but this seems not to work from Interface Builder.
How can I do this?
NSNumberFormatter doesn't work for you?
Try this on "changes ended" or whatever it is on the Mac.
- (IBAction) checkFloat: (id)sender
{
double test = [sender doubleValue];
if (test > 0.001)
[sender setStringValue:[NSString stringWithFormat:@"%E",test];
// etc.
}
Look up string formats here.
精彩评论