• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Number formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Number formatting (From: j o a r <email@hidden>)

  • Prev by Date: Re: Storing preferenses
  • Next by Date: Re: Number formatting
  • Previous by thread: Re: Number formatting
  • Next by thread: Re: Number formatting
  • Index(es):
    • Date
    • Thread