I’m trying to forward geocode 2 place names into coordinates with following code:
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:place inRegion:nil completionHandler:^(NSArray* placemarks, NSError* error){ NSLog(@"a"); NSLog(@"count %d", [placemarks count]); for (CLPlacemark* aPlacemark in placemarks) { CLLocationCoordinate2D coord = aPlacemark.location.coordinate; NSLog(@"%f, %f", coord.latitude, coord.longitude); } }]; [geocoder geocodeAddressString:place inRegion:nil completionHandler:^(NSArray* placemarks, NSError* error){ NSLog(@"b"); NSLog(@"count %d", [placemarks count]); for (CLPlacemark* aPlacemark in placemarks) { CLLocationCoordinate2D coord = aPlacemark.location.coordinate; NSLog(@"%f, %f", coord.latitude, coord.longitude); } }];
To simplify, I convert a single place name twice. When I run the code, only the first geocoding completion handler is runed. Remaining geocoding completion handlers are ignored.
I’d like to know why does it happen and how to convert more than one places.
See Apple’s guidance:
http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html