title: LocationServicesEnabled: APIs deprecated
body: <p>I use code from <a href="https://stackoverflow.com/questions/24252645/how-to-get-location-user-whith-cllocationmanager-in-swift">here</a>:</p>
  
  <pre><code>import UIKit 
  import CoreLocation
  
  @UIApplicationMain
  
  class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
  
  var window: UIWindow?
  var locationManager: CLLocationManager!
  var seenError : Bool = false
  var locationFixAchieved : Bool = false
  var locationStatus : NSString = "Not Started"
  
  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -&gt; Bool {
      initLocationManager();
      return true
  }
  
  // Location Manager helper stuff
  func initLocationManager() {
      seenError = false
      locationFixAchieved = false
      locationManager = CLLocationManager()
      locationManager.delegate = self
      locationManager.locationServicesEnabled
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
  
      locationManager.requestAlwaysAuthorization()
  }
  
  // Location Manager Delegate stuff
  
  func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) {
      locationManager.stopUpdatingLocation()
      if (error) {
          if (seenError == false) {
              seenError = true
             print(error)
          }
      }
  }
  
  func locationManager(manager: CLLocationManager!, didUpdateLocations locations: AnyObject[]!) {
      if (locationFixAchieved == false) {
          locationFixAchieved = true
          var locationArray = locations as NSArray
          var locationObj = locationArray.lastObject as CLLocation
          var coord = locationObj.coordinate
  
          println(coord.latitude)
          println(coord.longitude)
      }
  }
  
  func locationManager(manager: CLLocationManager!,
      didChangeAuthorizationStatus status: CLAuthorizationStatus) {
          var shouldIAllow = false
  
          switch status {
          case CLAuthorizationStatus.Restricted:
              locationStatus = "Restricted Access to location"
          case CLAuthorizationStatus.Denied:
              locationStatus = "User denied access to location"
          case CLAuthorizationStatus.NotDetermined:
              locationStatus = "Status not determined"
          default:
              locationStatus = "Allowed to location Access"
              shouldIAllow = true
          }
          NSNotificationCenter.defaultCenter().postNotificationName("LabelHasbeenUpdated", object: nil)
          if (shouldIAllow == true) {
              NSLog("Location to Allowed")
              // Start location services
              locationManager.startUpdatingLocation()
          } else {
              NSLog("Denied access: \(locationStatus)")
          }
  }
  }
  </code></pre>
  
  <p>But I have an error:
  <strong>'locationServicesEnabled' is unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift</strong>.</p>
  
  <p>Anyone know, how to fix that? </p>
  
  <p>Thanks!</p>