无法获得NSNumber的无符号长值

Flo*_*ked 6 iphone xcode objective-c

我想获得NSNumber的unsigned long值.我不知道为什么,但它不起作用.这是我做的:

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];
Run Code Online (Sandbox Code Playgroud)

Mat*_* B. 9

8084143463 == 0x1e1da3d67
3789176167 == 0x0e1da3d67
Run Code Online (Sandbox Code Playgroud)

64位系统上的长度大小为8个字节.32位系统(如iPhone)的长度为4个字节.您需要long long在iPhone上使用a 来存储该值.

  • 您还需要使用`%llu`的格式说明符. (3认同)