title: How to get location from GPS when offline in Swift?
body: <p>I want to make app can get location (latitude &amp; longitude) with no internet, and someone tell me use CCLocationManager, <a href="http://www.theappguruz.com/blog/using-gps-device-get-current-location-ios" rel="nofollow">here</a>.</p>
  
  <p>And I testing with my code: </p>
  
  <pre><code>var locationManager:CLLocationManager!
  
  @IBOutlet weak var locationTextField: UILabel!
  override func viewDidLoad() {
      super.viewDidLoad()
      locationManager = CLLocationManager()
      locationManager.delegate = self
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
      locationManager.requestAlwaysAuthorization()
      locationManager.startUpdatingLocation()
      let authstate = CLLocationManager.authorizationStatus()
      if(authstate == CLAuthorizationStatus.NotDetermined){
          print("Not Authorised")
          locationManager.requestWhenInUseAuthorization()
      }
      print("first")
      locationTextField.text = "11"
  
      // Do any additional setup after loading the view, typically from a nib.
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
      print("success \(locations.count)")
      let location:CLLocation = locations[locations.count - 1] as CLLocation
      print("aa:\(location.coordinate.latitude) \(location.coordinate.longitude)aa")
      locationTextField.text = location.description
  
  }
  
  func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
      print("Couldn't get your location with \(error.description)")
  }
  </code></pre>
  
  <p>But it just work with internet and when I turn off wifi, my app log: <code>Couldn't get your location with Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"</code></p>
  
  <p>Maybe I'm wrong somewhere, any helps, thanks.</p>