1
我想通过CLlocationManager对象在Xcode中使用coreloaction框架获取当前位置名称。当我在我的iPod touch上测试我的应用程序时,CLlocationManager为某些地方提供了值,但在许多地方返回[null]。我该如何纠正这个问题?帮我跟随编码。CLLocationManager为Xcode中的locality返回null
-(void)viewDidLoad
{
self.locationManager = [[CLLocationManager alloc] init] ;
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
[self.locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
if(error)
{
NSLog(@"error:%@",[error localizedDescription ]);
NSLog(@"Check your inetconnection");
}
_placedetail=nil;
self.placedetail=[placemarks objectAtIndex:0];
self.Label.text=self.placedetail.locality;
}];
[manager stopUpdatingLocation];//for stop process update
}