Reputation:
NSNumber *a;
for(NSDictionary *item in[res valueForKey:@"snapshot"])
{
a=[item valueForKey:@"lat"];
NSLog(@"%@",a);
b=[item valueForKey:@"lng"];
NSLog(@"%@",b);
}
that writes on console : ("29.13","29.38","29.31","29.30","29.43" ) ("94.13","94.38","93.30","94.58","94.34" )`
How could I get each values to convert double? I want to get each latitude and longitude pairs out of this output.
Upvotes: 0
Views: 272
Reputation: 32681
According to your NSLog
, the values you get from valueForKey:
are NSArrays
, not NSNumber
. So simply go thru those arrays.
for(NSDictionary *item in[res valueForKey:@"snapshot"])
{
NSArray* latitudesList = [item valueForKey:@"lat"];
NSArray* longitudesList = [item valueForKey:@"lng"];
NSInteger idx = 0;
NSInteger nb = MIN( latitudesList.count , longitudesList.count );
for(NSInteger idx = 0; idx < nb; ++idx)
{
double lat = [[latitudesList objectAtIndex:idx] doubleValue];
double lng = [[longitudesList objectAtIndex:idx] doubleValue];
NSLog(@"Pair #%d = { %f , %f }", idx, lat, lng);
}
}
Upvotes: 1