I need to convert a long value from int64 to NSData, so I can run the hash algorithm on it later. I am doing:
int64_t longNumber = 9000000000000000000L;
NSMutableData *buffer = [NSMutableData dataWithBytes:&longNumber length:sizeof(longNumber)];
NSLog(@"%lld", [buffer bytes]);
NSLog(@"%lld", longNumber);
The resulting console output is as follows:
6201314301187184 9000000000000000000
Why is NSData incorrectly storing a long number value? If I run this in a loop, the byte drift is NSData, starting at 620, then 621 onwards. Am I outputting the longNumber address via [buffer bytes], and not its value?
Demon kid
source
share