• 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:20:51 -0700

Thank you. The altered workaround code does work now. However, I more than likely will be asking some memory questions as the program works fine for several iterations then hangs with the spinning ball!!

John

On Tuesday, October 7, 2003, at 11:44 PM, Nick Zitzmann wrote:


On Tuesday, October 7, 2003, at 11:28 PM, John MacMullin wrote:

Again, the workaround code is:

NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init]
autorelease];

Here the program creates an autoreleased NSNumberFormatter.

[numberFormatter setLocalizesFormat:YES];
numberFormatter = [NSUnarchiver unarchiveObjectWithData: [NSArchiver archivedDataWithRootObject:numberFormatter]];

To quote the old MPW C compiler: "Huh?"

[numberFormatter setFormat:@"$#,##0.00"];
[numberFormatter stringForObjectValue:[[[self testFile]objectAtIndex:i]objectAtIndex:fieldFourNumberDef]];
fileFieldFourNumber = [fileFieldFourNumber stringByAppendingString:[NSString stringWithFormat:@"%@", numberFormatter]];

The third line in the block above is trying to get the description of the NSNumberFormatter, which is exactly what you're getting in the results (since NSNumberFormatter does not subclass -description). What you probably want to do instead is append the string that was generated in second line but not used or preserved anywhere...

Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page: http://seiryu.home.comcast.net/

"I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." - Bjarne Stroustrup
_______________________________________________
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: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: Number formatting
  • Next by Date: OT Re: Responder problem [flagsChanged cmd keyUp solved]
  • Previous by thread: Re: Number formatting
  • Next by thread: Re: Number formatting
  • Index(es):
    • Date
    • Thread