Converting a string to double for coordinate use, Xcode

Viewed 35579

I have a list of longitudes and latitudes in an XML file. I can print the lat and lon as a string but when i convert the string to a 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 log 'latstring' and 'lonstring' i get the correct coordinates however when i log 'latdouble' and 'londouble' i get 0.

I need the lat and lon values as double so i can use them in a mapview as it will not allow me to use a string for the coordinates.

There is probably a very simple explanation for this however i am fairly new to objective-c and cant seem to find a solution for this.

Any help is much appreciated.

2 Answers
Related