It may sound weird but I am facing a problem in calling a same block of code twice for different values. When the same code is repeated, I found that the first one only gets executed while second one is not even called. Please help
-(void) showRestaurants {
if (!self.geocoder) {
self.geocoder = [[CLGeocoder alloc] init];
}
NSArray *web = [detail valueForKeyPath:@"Address"];
NSLog(@"NO OF VALUES^^^^^^^^^^^^^^:: %@", web);
int count = [web count];
NSString *value;
//Other place of interest nearby
for (int i = 0; i < count; i++)
{
value = [web objectAtIndex:i];
NSLog(@"==> %@", value);
[self.geocoder geocodeAddressString:value completionHandler:^(NSArray *marks, NSError *failed) {
if ([marks count] > 0) {
NSLog(@"call Me....");
CLPlacemark *placemark = [marks objectAtIndex:0];
location = placemark.location;
coordinate = location.coordinate;
coordinate.latitude = location.coordinate.latitude;
coordinate.longitude = location.coordinate.longitude;
//for first co-ordinate :: SOURCE
MKCoordinateRegion newRegion;
newRegion.center.latitude = coordinate.latitude;
newRegion.center.longitude = coordinate.longitude;
newRegion.span.latitudeDelta = 0.029321;
newRegion.span.longitudeDelta = 0.034589;
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:coordinate];
//AppDelegate *dataCenter = (AppDelegate *) [[UIApplication sharedApplication] delegate];
[annotation setTitle:value];
[self.mapView addAnnotation:annotation];
[self.mapView setRegion:newRegion animated:YES];
}
}];
}
}