I have a list of longitudes and latitudes in an XML file. I can print lat and lon as a string, but when I convert the string to double, I get 0.
Here is my code:
NSString *latstring = [[NSString alloc] initWithString:theList.lat] ;
NSString *lonstring = [[NSString alloc] initWithString:theList.lon];
NSLog(@"latstring: %@, lonstring: %@", latstring, lonstring);
double latdouble = [latstring doubleValue];
double londouble = [lonstring doubleValue];
NSLog(@"latdouble: %g, londouble: %g", latdouble, londouble);
When I write 'latstring' and 'lonstring', I get the correct coordinates, however, when I write 'latdouble' and 'londouble', I get 0.
I need lat and lon values as double, so I can use them in mapview, since it will not allow me to use a string for coordinates.
This is probably a very simple explanation, but I'm pretty new to objective-c and can't find a solution for this.
Any help is greatly appreciated.
source
share