title: Get the speed by Swift 2 with CLLocation
body: <p>I try to make an application in Swift 2 that displays all the GPS informations.
  I can recover latitute, longitue, horizontalAccuracy, verticalAccuracy, altitude, distance and cap but I am unable to recover speed, whereas I arrived in Objective-C :-(</p>
  
  <p>Thanks for your help</p>
  
  <p>Below is my code:</p>
  
  <pre><code>import UIKit
  import CoreLocation
  
  class ViewController: UIViewController, CLLocationManagerDelegate {
  
  var running = false
  var pause = false
  var locationManager: CLLocationManager = CLLocationManager()
  var startLocation: CLLocation!
  
  @IBOutlet weak var latitudeLabel: UILabel!
  @IBOutlet weak var longitudeLabel: UILabel!
  
  @IBOutlet weak var horizontalAccuracyLabel: UILabel!
  @IBOutlet weak var verticalAccuracyLabel: UILabel!
  
  @IBOutlet weak var capLabel: UILabel!
  @IBOutlet weak var altitudeLabel: UILabel!
  
  
  @IBOutlet weak var partielLabel: UILabel!
  @IBOutlet weak var distanceLabel: UILabel!
  
  @IBOutlet weak var vitesseLabel: UILabel!
  @IBOutlet weak var moyenneLabel: UILabel!
  @IBOutlet weak var timerLabel: UILabel!
  @IBOutlet weak var totalDistanceLabel: UILabel!
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
      locationManager.delegate = self
      locationManager.requestWhenInUseAuthorization()
      locationManager.startUpdatingLocation()
      locationManager.startUpdatingHeading()
      startLocation = nil
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  @IBAction func startDistance(sender: AnyObject) {
      startLocation = nil
      running = true
  }
  
  @IBAction func stopDistance(sender: AnyObject) {
      running = false
  }
  
  @IBAction func resetDistance(sender: AnyObject) {
      startLocation = nil
  }
  
  
  func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
  {
      let latestLocation: AnyObject = locations[locations.count - 1]
  
      latitudeLabel.text = String(format: "%.4f",latestLocation.coordinate.latitude)
      longitudeLabel.text = String(format: "%.4f",latestLocation.coordinate.longitude)
  
      horizontalAccuracyLabel.text = String(format: "%.4f",latestLocation.horizontalAccuracy)
      verticalAccuracyLabel.text = String(format: "%.4f",latestLocation.verticalAccuracy)
  
      altitudeLabel.text = String(format: "%.4f",latestLocation.altitude)
  
      if running == true {
          if startLocation == nil {
              startLocation = latestLocation as! CLLocation
          }
  
          let distanceBetween: CLLocationDistance =
          latestLocation.distanceFromLocation(startLocation)
  
          distanceLabel.text = String(format: "%.2f", distanceBetween)
      }
  }
  
  func locationManager(manager: CLLocationManager, didUpdateHeading newHeading: CLHeading)
  {
      capLabel.text = String(format: "%.4f",newHeading.magneticHeading)
  }
  
  
  func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I tested this code : </p>
  
  <pre><code>vitesseLabel.text = String(CLLocationSpeed())
  </code></pre>
  
  <p>but speed remains at 0.00</p>