The correct way to request and update the location of the user (s) is via CLLocationManagerDelegate .
As long as your view controller inherits CLLocationManagerDelegate , it does not seem to perform the necessary delegate functions. As @Rob already mentioned, you should declare locationManager as a class property, and not as a local variable.
This delegate function allows you to implement logic if / when the user changes the authorization status:
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { if status == .AuthorizedWhenInUse { // authorized location status when app is in use; update current location locationManager.startUpdatingLocation() // implement additional logic if needed... } // implement logic for other status values if needed... }
This delegate function allows you to implement logic if / when changing a user's location:
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { if let location = locations.first as? CLLocation { // implement logic upon location change and stop updating location until it is subsequently updated locationManager.stopUpdatingLocation() } }
In addition, locationServicesEnabled() determines whether the user has location services enabled.
source share