Re: Number formatting
Re: Number formatting
- Subject: Re: Number formatting
- From: John MacMullin <email@hidden>
- Date: Wed, 8 Oct 2003 12:15:18 -0700
Thank you. I had read the data formatting documentation in the throes
of working through the code came across the bug workaround and presumed
its workability.
John
On Tuesday, October 7, 2003, at 11:58 PM, j o a r wrote:
Have you read this John?
<http://developer.apple.com/documentation/Cocoa/Conceptual/
DataFormatting/index.html>
Notice that the "stringForObjectValue:" method returns a formatted
string, but you're not "catching" it...
In the code below you're printing the formatter itself, not the string
value returned from the formatter. Try something like this:
NSString *formattedStr = [numberFormatter stringForObjectValue:
[[[self testFile] objectAtIndex: i] objectAtIndex:
fieldFourNumberDef]];
NSLog(@"str. %@", formattedStr);
j o a r
On 2003-10-08, at 08.28, John MacMullin wrote:
Ok, that worked for the compile. However, now when I execute the
code I get the following output in the string: <NSNumberFormatter
0x12f8d00> which is obviously not a currency formatted number.
Again, the workaround code is:
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init]
autorelease];
[numberFormatter setLocalizesFormat:YES];
numberFormatter = [NSUnarchiver unarchiveObjectWithData: [NSArchiver
archivedDataWithRootObject:numberFormatter]];
[numberFormatter setFormat:@"$#,##0.00"];
[numberFormatter stringForObjectValue:[[[self
testFile]objectAtIndex:i]objectAtIndex:fieldFourNumberDef]];
fileFieldFourNumber = [fileFieldFourNumber
stringByAppendingString:[NSString stringWithFormat:@"%@",
numberFormatter]];
_______________________________________________
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.