Saving longLong value using CoreData in iPhone SDK

I am trying to store a long long value using Core Data. A value similar to 119143881477165. I store the value in NSNumber, which is created using the method method methodWithUnsignedLongLong. The master data metadata is of type int64 for this field. The number is stored correctly, however, when I get this number using unsignedLongLongValue, the value is truncated.

Any suggestions?

+2
source share
1 answer

You say that it is truncated ... what type of primitive do you store the value? If you use NSUInteger, it is possible that the platform you are working on is defined as unsigned int, rather than unsigned long.

long long, long long.

:

unsigned long long number = 119143881477165;
NSNumber * numberValue = [NSNumber numberWithUnsignedLongLong:number];
unsigned long long extracted = [numberValue unsignedLongLongValue];

NSLog(@"original: %llu", number);
NSLog(@"extracted: %llu", extracted);

:

2010-10-04 00: 39: 25.103 EmptyFoundation [790: a0f] : 119143881477165

2010-10-04 00: 39: 25.106 EmptyFoundation [790: a0f] : 119143881477165

+3

All Articles