Hi there,

has anybody successfully used NSNumberFormatter's new setLenient: feature that was introduced with 10.5 together with one of the common number styles like currency or percent? As usual, I want the formatter to show a currency or percent symbol when turning numbers into strings but to be forgiving of omitted symbols when converting a user's string input into numbers.

The following code

        NSNumberFormatter *percentFormatter = [[NSNumberFormatter alloc] init];
        percentFormatter.formatterBehavior = NSNumberFormatterBehavior10_4;
        percentFormatter.numberStyle = NSNumberFormatterPercentStyle;
        [percentFormatter setLenient:YES];
        NSLog(@"%@", [percentFormatter numberFromString:@"10"]);

outputs "(null)".  The same happens with the currency style.

Is there any way to get a lenient behavior from NSNumberFormatter without having to subclass it?

Cheers

 Frank


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to