我只想检查一下是否正确,我正在创建一个CCLocationManager实例,然后检查是否启用了位置服务。如果没有启用它,我就会报告一个错误,释放实例并继续,这样看起来/听起来对吗?
locationManager = [[CLLocationManager alloc] init];
BOOL supportsService = [locationManager locationServicesEnabled];
if(supportsService) {
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
} else {
NSLog(@"Location services not enabled.");
[locationManager release];
}
...
...
... more code干杯加里
发布于 2010-05-19 20:48:44
为了防止进一步的错误,您可以在发布后将locationManager设置为nil。除此之外,您的方法没有任何问题。
https://stackoverflow.com/questions/2865566
复制相似问题