Re: NSNumberFormatter not working for me ?
Re: NSNumberFormatter not working for me ?
- Subject: Re: NSNumberFormatter not working for me ?
- From: Bill Hernandez <email@hidden>
- Date: Tue, 13 Apr 2010 18:37:23 -0500
On Apr 13, 2010, at 5:50 PM, Murat Konar wrote:
> For one thing, the docs say that -setFormat: is for use with formatters using NSNumberFormatterBehavior10_0 behavior.
>
> Have you set the formatters behavior?
murat,
No, just the way the code showed. Here's from the docs :
-- From what I can see it should work out or the box ???
NSNumberFormatterBehavior10_0
The number-formatter behavior as it existed prior to Mac OS X v10.4.
Available in Mac OS X v10.4 and later.
I added : [NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0];
but it didn't help...
// +---------+---------+---------+---------+---------+---------+---------+---------+
+ (NSString *)bhFormatNumberString:(NSString *)aNumberString withFormat:(NSString *)aFormat
{
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[NSNumberFormatter setDefaultFormatterBehavior:NSNumberFormatterBehavior10_0];
[numberFormatter setFormat:aFormat]; // specify just positive values format
NSInteger theInt = [aNumberString intValue];
NSNumber *theNum = [NSNumber numberWithInt:theInt];
NSString *theString = (NSString *)[numberFormatter stringFromNumber:theNum];
NSLog(@"[4625] theString = %@", theString);
return theString;
// +---------+---------+---------+---------+---------+---------+---------+---------+
}
Bill Hernandez
Plano, Texas
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden