Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can´t get the unsigned long value of a NSNumber

I want to get the unsigned long value of a NSNumber. I don´t know why, but it doesn't work. Here is what I did:

NSString * stern = [idd objectAtIndex:indexPath.row]; // get a String with Number from a NSArray
NSNumberFormatter * lols = [[NSNumberFormatter alloc] init];
NSNumber * iddd = [lols numberFromString:stern];
NSLog(@"%@", iddd); // I get the right number: 8084143463
unsigned long fooo = [iddd unsignedLongValue];
NSLog(@"%lu", fooo); // I get the wrong number: 3789176167
[twitterEngine deleteUpdate:fooo];
like image 541
Flocked Avatar asked Jan 22 '10 23:01

Flocked


1 Answers

8084143463 == 0x1e1da3d67
3789176167 == 0x0e1da3d67

The size of a long on a 64bit system is 8 bytes. The size of a long on a 32bit system (like the iPhone) is 4 bytes. You need to use a long long on an iPhone to store that value.

like image 57
mbauman Avatar answered Sep 22 '22 07:09

mbauman