title: iOS & Swift: display distance from current location?
body: <p>I have scoured the interwebs and stackoverflow, and I can't find a solution to my problem.</p>
  
  <p>I am attempting to:</p>
  
  <ol>
  <li>Get a user's current location (lat &amp; long)</li>
  <li>Calculate the distance between a user's current location and another location (lat &amp; long) that I set internally</li>
  <li>Return the distance in a list view</li>
  </ol>
  
  <p>So far, I can accomplish this if I manually set my current location, but I need to to update.</p>
  
  <p>I have had success returning my current location (I set it as Apple headquarters in the Simulator) in the log, but no success in the actual app or simulator.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>import UIKit
  import CoreLocation
  import MapKit
  
  class ViewController: UITableViewController, CLLocationManagerDelegate, MKMapViewDelegate {
  
  
  
  
  override func prefersStatusBarHidden() -&gt; Bool {
      return true
  }
  
  
  var shops = [coffeeShop]()
  
  var locationManager = CLLocationManager()
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  
  
      // Ask for Authorisation from the User.
      self.locationManager.requestAlwaysAuthorization()
  
      // For use in foreground
      self.locationManager.requestWhenInUseAuthorization()
  
      if CLLocationManager.locationServicesEnabled() {
          locationManager.delegate = self
          locationManager.desiredAccuracy = kCLLocationAccuracyBest
          locationManager.startUpdatingLocation()
      }
  
  
  
  
      loadShops()
  
  }
  
  
  func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
      let locValue:CLLocationCoordinate2D = manager.location!.coordinate
              print("locations = \(locValue.latitude) \(locValue.longitude)")
  
  }
  
  
  func loadShops() {
  
      let currentLocation = CLLocation()
      let currentLat = currentLocation.coordinate.latitude
      let currentLong = currentLocation.coordinate.longitude
  
  
      var myLocation = CLLocation(latitude: currentLat, longitude: currentLong)
  
  
      let shopLocation1 = CLLocation(latitude: 39.7886939, longitude: -86.1547275)
      let distance1 = myLocation.distanceFromLocation(shopLocation1) / 1000
      let shop1 = coffeeShop(location: distance1)!
  
  }
  </code></pre>
  
  <p>In addition, I have everything set in the info.plist and all of that good stuff.</p>
  
  <p>HOW DO I MAKE THIS WORK!? * <em>weeps softly</em> *</p>
  
  <p>Thanks in advance for all of your help!</p>