I am trying to store latitude / longitude in master data. They ultimately have an accuracy of 6 to 20 digits.
And for some reason, I used them as floating in Core Data, rounding them up and not giving me exact values. I tried the "decimal" type, and no luck.
Is NSStrings my only other option?
EDIT
NSManagedObject:
@interface Event : NSManagedObject { } @property (nonatomic, retain) NSDecimalNumber * dec; @property (nonatomic, retain) NSDate * timeStamp; @property (nonatomic, retain) NSNumber * flo; @property (nonatomic, retain) NSNumber * doub;
Here is the code for the sample number that I store in the master data:
NSNumber *n = [NSDecimalNumber decimalNumberWithString:@"-97.12345678901234567890123456789"];
The above value is printed. Sweet, the value I was expecting:
Printing description of n: -97.12345678901234567890123456789
The code to access it again:
NSNumber *n = [managedObject valueForKey:@"dec"]; NSNumber *f = [managedObject valueForKey:@"flo"]; NSNumber *d = [managedObject valueForKey:@"doub"];
Printed Values:
Printing description of n: -97.1234567890124 Printing description of f: <CFNumber 0x603f250 [0xfef3e0]>{value = -97.12345678901235146441, type = kCFNumberFloat64Type} Printing description of d: <CFNumber 0x6040310 [0xfef3e0]>{value = -97.12345678901235146441, type = kCFNumberFloat64Type}
ios iphone core-location
Bryan
source share