Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

petron

macrumors member
Original poster
May 22, 2009
95
0
Malmo, Sweden
Hi,

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:

Code:
- (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
/petron
 

chrono1081

macrumors G3
Jan 26, 2008
8,468
4,313
Isla Nublar
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.
 

petron

macrumors member
Original poster
May 22, 2009
95
0
Malmo, Sweden
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.

/petron
 

TheMacintosh

macrumors newbie
Jul 27, 2009
4
0
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
 

petron

macrumors member
Original poster
May 22, 2009
95
0
Malmo, Sweden
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.

/piotr
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.