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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to