Open thebaotran opened 7 years ago
You need to store them as NSNumber instead of NSValue. If you properly box @10158365420975381
when storing, then the condition ![value isKindOfClass:[NSNumber class]]
will not match and it will not call MR_numberFromString
.
When integrating with the Facebook API to get my friend's UID, they are returned as ints and I'm storing them as int64 in Objective-C (longlong). I'm calling MR_importFromArray which eventually calls:
MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData
. It eventually hits this block of code: https://github.com/magicalpanda/MagicalRecord/blob/3560a8c628101eb0810e55295234106d9eb7ef36/MagicalRecord/Categories/DataImport/NSAttributeDescription%2BMagicalDataImport.m#L48-L57The error occurs in MR_numberFromString when converting the value to a double:
[NSNumber numberWithDouble:[value doubleValue]];
Specifically, my test value is 10158365420975381 and this function is returning 10158365420975380. There are other values that are off by 1 as well.
I've fixed this issue by storing the value as a string instead, but if wanting to store as an int, this will cause problems.