• 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: 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.

  • Follow-Ups:
    • Re: Number formatting
      • From: John MacMullin <email@hidden>
References: 
 >Re: Number formatting (From: John MacMullin <email@hidden>)

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