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

akshays

macrumors newbie
Original poster
May 20, 2009
1
0
I am loading information from an xml file and have found that one variable from the file <Value>1</Value> gets scanned correctly by the following code:

int tmp;
[[NSScanner scannerWithString: [oneAreaChild objectValue]] scanInt: &tmp];
[myClass setWidth: tmp];

On the other inside myClass (I stopped using @property int width) I have created the following setter:

- (void) setWidth: (int) tmp
{
width = tmp;
}

Amazingly the scanned value of tmp in the first piece of code is 1 and on the other end when passed is some 1034579822 or some random value.

This is the most amazing bug or am I doing something wrong here.

Doesnt matter if you @synthesize and use a property instead it screws up in the same way lol.

Also more confusing I repeat this style of code for other values from the XML file integers no less and they initialize the class value perfectly from the XML file. Just 2 values are getting butchered for no apparent reason.

Thanks in advance for the help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.