Re: Number formatting
Re: Number formatting
- Subject: Re: Number formatting
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 7 Oct 2003 23:44:37 -0700
On Tuesday, October 7, 2003, at 11:28 PM, John MacMullin wrote:
Again, the workaround code is:
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init]
autorelease];
Here the program creates an autoreleased NSNumberFormatter.
[numberFormatter setLocalizesFormat:YES];
numberFormatter = [NSUnarchiver unarchiveObjectWithData: [NSArchiver
archivedDataWithRootObject:numberFormatter]];
To quote the old MPW C compiler: "Huh?"
[numberFormatter setFormat:@"$#,##0.00"];
[numberFormatter stringForObjectValue:[[[self
testFile]objectAtIndex:i]objectAtIndex:fieldFourNumberDef]];
fileFieldFourNumber = [fileFieldFourNumber
stringByAppendingString:[NSString stringWithFormat:@"%@",
numberFormatter]];
The third line in the block above is trying to get the description of
the NSNumberFormatter, which is exactly what you're getting in the
results (since NSNumberFormatter does not subclass -description). What
you probably want to do instead is append the string that was generated
in second line but not used or preserved anywhere...
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://seiryu.home.comcast.net/
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my
telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.