set your variable to 0 before you set it
int oldId = 0
oldid = [NSNumber numberWithInt:client.oldId];
sometimes you can get garbage in a memory location that can cause this.
Updated Answer: Though technically sometimes I have found that if you dont clear out the integer I get the same thing. In this case he was setting an int
to an NSNumber
. The correct way was to take the NSNumber and get its integerValue
like this:
[client.oldId intValue]