I am using the code below. I could successfully get the string value. But when it is converted to NSInteger
, a minus appears in the front, and the value changes. Am I missing something?
NSInteger bannerStamp = [[eachDict objectForKey:@"timeStamp"] integerValue];
NSLog(@"%@",[eachDict objectForKey:@"timeStamp"]);
NSLog(@"%d",bannerStamp);
OUTPUT
2015-01-01 10:44:52.482 SalesApp[24570:60b] 3597478187
2015-01-01 10:44:54.094 SalesApp[24570:60b] -697489109
try to convert into long long value
long long bannerStamp = [[eachDict objectForKey:@"timeStamp"] longLongValue];
NSLog(@"%@",[eachDict objectForKey:@"timeStamp"]);
NSLog(@"%lld",bannerStamp);
Here is the difference between 32-bit and 64-bit architecture,
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
Apple document link for changes to data types