我的问题是,当addressTF.text有一个非常合理的地址字符串时,为什么poiCoordinate的纬度和经度属性会出现0,0,例如“1 Infinite Loop,Cupertino,CA 95014”?
//HomeViewController.m
@implementation HomeViewController
CLLocationCoordinate2D poiCoordinate;
-(void)performStringGeocode
{
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:_addressTF.text completionHandler:^(NSArray *placemarks, NSError *error)
{
if (error)
{
NSLog(@"Geocode failed with error: %@", error);
return;
}
CLPlacemark *placemark = [placemarks firstObject]; //Line A
poiCoordinate = placemark.location.coordinate; //Line B
}];
}