我的應用程序使用啓動CLLocationManager的典型模式,然後在newLocation
足夠準確的情況下從locationManager:didUpdateToLocation:fromLocation:
調用stopUpdatingLocation
。我的問題是我是否也需要致電我應該在locationManager中發送[locationManager stopUpdatingLocation]:didFailWithError :?
[locationManager stopUpdatingLocation];
in locationManager:didFailWithError:
。蘋果的文檔說
If the location service is unable to retrieve a location right away, it reports a
kCLErrorLocationUnknown
error and keeps trying. In such a situation, you can simply ignore the error and wait for a new event.If the user denies your application’s use of the location service, this method reports a
kCLErrorDenied
error. Upon receiving such an error, you should stop the location service.
在前者的情況下,我不應該叫stopUpdatingLocation
,因爲外景經理仍然可以發出一個很好的位置。其他情況呢?在嘗試使用位置服務之前,我的應用始終檢查[CLLocationManager locationServicesEnabled]
和[CLLocationManager authorizationStatus]
,所以我真的需要處理kCLErrorDenied
的情況嗎?如果發生任何其他錯誤,位置服務是否會自動停止?