I am getting the latitude and longitude from the api, and need to get the place name from these cooridinates so that I use this block of code
CLGeocoder *ceo = [[CLGeocoder alloc]init];
CLLocation *LocationAtual=[[CLLocation alloc] initWithLatitude:[[latlong objectForKey:@"latitude"] doubleValue]
longitude:[[latlong objectForKey:@"longitude"] doubleValue]];
NSLog(@"loc %@", LocationAtual);
[ceo reverseGeocodeLocation:LocationAtual completionHandler:^(NSArray *placemarks, NSError *error)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSLog(@"placemark %@",placemark);
//String to hold address
NSString *locatedAt = [[placemark.addressDictionary valueForKey:@"FormattedAddressLines"] componentsJoinedByString:@", "];
NSLog(@"addressDictionary %@", placemark.addressDictionary);
NSLog(@"placemark %@",placemark.region);
NSLog(@"placemark %@",placemark.country); // Give Country Name
NSLog(@"placemark %@",placemark.locality); // Extract the city name
NSLog(@"location %@",placemark.name);
NSLog(@"location %@",placemark.ocean);
NSLog(@"location %@",placemark.postalCode);
NSLog(@"location %@",placemark.subLocality);
NSLog(@"location %@",placemark.location);
NSLog(@"I am currently at %@",locatedAt);
NSLog(@" ");
}
];
But when my control goes on this line
[ceo reverseGeocodeLocation:LocationAtual completionHandler:^(NSArray *placemarks, NSError *error)
this block of code is not executed. Control goes.