获取城市的名字,具体还可以获得街道信息,不多说直接上代码:
CLLocation *currentLocation = [locations lastObject];
MJLog(@"currentLocation == %@",currentLocation);
// 创建位置
CLGeocoder *revGeo = [[CLGeocoder alloc] init];
[revGeo reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
// 地理位置反编
if (!error && [placemarks count] > 0) {
NSDictionary *dict = [[placemarks objectAtIndex:0] addressDictionary];
_currentPosition = [dict objectForKey:@"City"];
MJLog(@"City address: %@",_currentPosition); }
else {
Alert(@"温馨提示", @"获取位置失败");
MJLog(@"ERROR: %@", error); }
}];