View Full Version : Hillgass RaiseMan Number Formatter problems

Jul 25, 2009, 04:16 PM

I just went through some of the examples in the Aaron's book. I am now by chapter 15 but I realized that I still have some strange problems with the NSNumberFormatter, I thought it has been solved earlier.

For those of you who went through the book it is enough to say that the problem is with the percent formatted column of the RaiseMan tableView.

The second column contains the pay raise percentage representation. I did formatted it to "percent". It look like not a big deal but it behaves strangely.

1. When I start the application and press "Add New Employee", en object entry is created with default name, one can now write a specific name, then the percentage rate is filled by the default value that is specified in the init part of the Person class. in my case it is like this:

- (id)init {
[super init];
expectedRaise = 5.0;
personName = @"New person";
return self;

So one can see the 5,0 in the filed. and all seems fine.

2. When I add a second person and do change its expectedRaise to anything, lets say to 2%, then the first persons expectedRaise will change to 500% but in the code/logger there is still correct value 5%. The second person's expectedRaise is logged as 0,02.

3. When I save the file and open it again the first person's expectedRaise is 5% while the second person's expectedRaise is 0,02%

4. When I add a new person and start editing the expectedRaise value then all the values will be again changed, multiplied by 100.

I do not know what is happening. Seems like there is a multiply or divide 100 factor somewhere.

if I do not change the default expectedRaise values even if I add lots of persons the displayed value is correct. But if I even change a single value all the values displayed are multiplied by hundred.

I changed the formatter to "decimal" and there are no such a problems at all.
I even tried with currency, and it works fine there too even if it looks stupid.

I will appreciate some ideas that may help to catch the problem.

Best regards

Jul 26, 2009, 01:27 PM
There is a bug in NSNumberFormatter

Bug ID = 5756666

It is probably fixed in Snow Leopard release.


Jul 27, 2009, 04:13 AM
Out of curiosity what is the name of the book? I always see it mentioned but there are several books by Hillegass and I'm not sure which one everyone is reading that has this Raiseman program.

Jul 27, 2009, 05:36 AM
Hi Chrono.

The last edition of:
Cocoa Programming for Mac OS X

Pretty good book, takes you through the whole bunch of subject via examples.
Additionally there are some challenge exercises to do that force your fingers into the keyboard and add some discussions to that list.


Jul 27, 2009, 06:27 AM
Thank you. Its in my shopping cart on amazon as we speak :)

Jul 27, 2009, 11:17 PM
Try rewriting it. RaiseMan is quite simple, and should work the first time. What OS are you on? It works perfectly on 10.5.7

Jul 28, 2009, 02:09 AM
Hi TheMacintosh.

I do not remember what OS I do have ( one of the latest - I am not at home right now) but it should be no differance. The "percent bug" has been there since 10.4 and will be there untill Snow Leopard will shows up in september.

What rewrite are you talking about, I am a bit confused so I will apreciate more information.

As far I have got only three ideas.
1. Change the NSNumberFormatter to handle decimal numbers instead and change the title of the expectedRais column in the viewTable.
2. Create a new class based on NSNumberFormatter, use all from the mother and override only "getObjectValue:..."
3. There are som people saying that if one disable the group separator it works. I was not able to get it working this way.