• 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: NSNumber Formatter with percent?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumber Formatter with percent?


  • Subject: Re: NSNumber Formatter with percent?
  • From: Christopher Kane <email@hidden>
  • Date: Sat, 26 Jul 2008 09:45:33 -0700

On Jul 19, 2008, at 5:13 PM, Todd Heberlein wrote:
I was working through Hillegass's latest book and chapter 8 has me applying an NSNumberFormatter to one of the columns of a table view. Unfortunately I get unexpected behavior when I modify one of the values in the column. For example, if I add several employees (which have a default value of 5%), then I modify one of the numbers (say to 7%) then *all* the other number values get displayed as 500%. Furthermore, all new values are automatically displayed with a raise of 500% (as opposed to just 5%).


This is a known bug in 10.5 with NSNumberFormatter (and perhaps earlier), when the string to be parsed can't be initially parsed and has to try again in a different way.

As for the suggestion to use the 10.0 behavior mode, the multiplier property and the percent style don't work with 10.0 behavior, so you'll have to roll your own percent handling and multiplication and division.

A workaround for 10.5 might be to set the multiplier after each string- >number parse attempt (and the various methods which do that). Something like [formatter setMultiplier:[formatter multiplier]] perhaps, due to the indirect things that happen when you do that. This is not particularly easy though if you have a number formatter set up in a nib file and/or attached to a cell. You might subclass NSNumberFormatter, or implement a post-user-input delegate method on the particular control, or perhaps something else.


Chris Kane Cocoa Frameworks, Apple

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSNumber Formatter with percent? (From: Todd Heberlein <email@hidden>)

  • Prev by Date: Re: How to locate coding examples for specified commands [Newbie]
  • Next by Date: Re: unsigning NSNumber
  • Previous by thread: Re: NSNumber Formatter with percent?
  • Next by thread: drawRect infinite loop -- argh!
  • Index(es):
    • Date
    • Thread