Number formatting
Number formatting
- Subject: Number formatting
- From: John MacMullin <email@hidden>
- Date: Tue, 7 Oct 2003 21:30:19 -0700
Charles Srstka posted the following, also on mamasam, regarding a
workaround with respect to number formatting.
NSNumberFormatter *nf = [[[NSNumberFormatter alloc] init] autorelease];
[nf setLocalizesFormat:YES];
nf = [NSUnarchiver unarchiveObjectWithData:
[NSArchiver archivedDataWithRootObject:nf]];
[nf setFormat:@"0"];
[nf setHasThousandSeparators:YES];
[sizeField setStringValue:[NSString stringWithFormat:@"%@ (%@ %@)",
[item stringRepresentationOfSize],
[nf stringForObjectValue:[NSNumber numberWithUnsignedLong:[item
sizeInBytes]]],
NSLocalizedString(@"bytes",@"")]];
I followed this example writing the following code: (I am just trying
to format a float number to a currency)
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]];
When I compile however I get the following message: MyDocument.m:639:
error: stray '\312' in program
Project Builder refers me to the third line above.
Any suggestions on fixing this error?
John
_______________________________________________
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.