CLGeocoder反解析用户的地址

UIlael lab_Area


-(void)getUserCurrentAddress

{

CLGeocoder *geoCoder=[[CLGeocoder alloc]init];
AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
CLLocation *mycurLocaton=[[CLLocation alloc]initWithLatitude:delegate.currentCoordinate.latitude longitude:delegate.currentCoordinate.longitude];
//反解析
[geoCoder reverseGeocodeLocation:mycurLocaton completionHandler:^(NSArray *places,NSError *error){
CLPlacemark *aPlace=[places objectAtIndex:0];
if (aPlace.name==nil) {
[lab_Area setText:@"无法获取信息"];
}else
{
[lab_Area setText:aPlace.name];
}
[geoCoder release];
[mycurLocaton release];
}];
}

你可能感兴趣的:(code)