このコードをviewcontroller.mに実装すると、「メソッド宣言のコンテキストがありません」というエラーが表示されます。
- (void)searchBarSearchButtonClicked:(UISearchBar *)theSearchBar {
[theSearchBar resignFirstResponder];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:theSearchBar.text completionHandler:^(NSArray *placemarks, NSError *error) {
//Error checking
CLPlacemark *placemark = [placemarks objectAtIndex:0];
MKCoordinateRegion region;
region.center.latitude = placemark.region.center.latitude;
region.center.longitude = placemark.region.center.longitude;
MKCoordinateSpan span;
double radius = placemark.region.radius / 1000; // convert to km
NSLog(@"[searchBarSearchButtonClicked] Radius is %f", radius);
span.latitudeDelta = radius / 112.0;
region.span = span;
[theMapView setRegion:region animated:YES];
}];
}