I have a view controller which implements the CLLocationManagerDelegate
. I create a the CLLocationManager variable:
let locationManager = CLLocationManager()
Then in the viewDidLoad
, I set properties:
// Set location manager properties
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
locationManager.distanceFilter = 50
The problem comes that the function gets called even before I check the authorization status.
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
if (status == .AuthorizedWhenInUse) {
// User has granted autorization to location, get location
locationManager.startUpdatingLocation()
}
}
Can anyone inform me what could be causing this to occur?