I have an app that drops multiple annotations, and I want to reverse geocode the pin locations and set the address as the subtitle. Here is the code I have so far, but I do not know how to implement the reverse geocoder.
-(void)press:(UILongPressGestureRecognizer *)recognizer
{
CGPoint touchPoint = [recognizer locationInView:worldView];
CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];
if (UIGestureRecognizerStateBegan == [recognizer state]) {
MapPoint *mp = [[MapPoint alloc]initWithCoordinate:touchMapCoordinate
title:@"Dream House"];
[worldView addAnnotation:mp];
geocoder = [[CLGeocoder alloc]init];
CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
altitude:CLLocationDistanceMax
horizontalAccuracy:kCLLocationAccuracyBest
verticalAccuracy:kCLLocationAccuracyBest
timestamp:[NSDate date]];
[geocoder reverseGeocodeLocation:location
completionHandler:^(NSArray *placemarks, NSError *error) {
<#code#>
}];
}
}
The pins would be dropped on homes, so I just want to show the house address. Thanks for the help.