【发布时间】:2014-01-27 00:03:35
【问题描述】:
我对@987654322@ 有疑问,如果我尝试使用CLGeocoder 获取地址名称并且用户当前坐标正确返回NSLog 中的地址名称、邮政编码、州等,但如果我尝试在NSString 中发送这些信息[包含在NSMutableArray 中,但我认为这不是问题] 它返回(null) 值。我怀疑这个问题是由我在代码中使用的块引起的,但我不确定,我也不知道如何解决这个问题。
这是我的代码:
- (NSArray *)dataArrayPosizione
{
if (self.arrayPosizione == nil)
{
reverseGeocoder = [[CLGeocoder alloc] init];
locationToReverseGeocode = [[CLLocation alloc]initWithLatitude:self.mapView.userLocation.location.coordinate.latitude longitude:self.mapView.userLocation.location.coordinate.longitude];
[reverseGeocoder reverseGeocodeLocation:locationToReverseGeocode completionHandler:^(NSArray *placemarks, NSError *error)
{
if (placemarks && placemarks.count > 0)
{
placemark = placemarks[0];
NSLog(@"\n%@ %@\n%@, %@, %@\n%@", [placemark subThoroughfare],[placemark thoroughfare], [placemark locality], [placemark administrativeArea], [placemark postalCode], [placemark country]);
}
}];
informazioniPosizione = [NSMutableArray new];
[informazioniPosizione addObject:[NSString stringWithFormat:@"Indirizzo: %@", [placemark country]]];
[informazioniPosizione addObject:[NSString stringWithFormat:@"Latitudine: %g\u00B0\nLongitudine: %g\u00B0", self.mapView.userLocation.location.coordinate.latitude, self.mapView.userLocation.location.coordinate.longitude]];
self.arrayPosizione = informazioniPosizione;
}
return self.arrayPosizione;
}
还有一张图片:
有人可以帮我解决这个问题吗?如果发布的代码不足以让您理解问题,我将粘贴更多行。
谢谢
【问题讨论】:
标签: ios objective-c objective-c-blocks cllocation clgeocoder