Re: Number formatting
Re: Number formatting
- Subject: Re: Number formatting
- From: j o a r <email@hidden>
- Date: Wed, 8 Oct 2003 08:58:57 +0200
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.