我有一个调用来获取用户位置的应用程序:
-(void)getLocation{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
//SET USER LOCATION
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
self.userLocation = [locations lastObject];
NSLog(@"location in IntroVC %f, %f", self.userLocation.coordinate.latitude, self.userLocation.coordinate.longitude);
}
我的问题是,因为 NSLog 不断吐出一个新的位置,我应该什么时候停止调用该位置?好吧,我想这真的取决于我的应用程序的功能,但这不会导致电池耗尽吗?如果是这样,我真的应该研究停止更新的最佳方法。