I am creating a based application CoreLocationthat shows the user my location based on 6 parameters, such as Latitude, longitude, horizontal accuracy, height, vertical accuracy, distance traveled .
It is assumed that the user must first allow access to the location, but I also tried to reset all the simulator settings.

The gray part will be filled in with the card later.
This is what my View.Controller.swift looks like :
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
private let LocationManager = CLLocationManager()
private var previousPoint:CLLocation?
private var totalMovementDistance:CLLocationDistance = 0
@IBOutlet var latitudeLabel: UILabel!
@IBOutlet var longitudeLabel: UILabel!
@IBOutlet var horizontalAccuracy: UILabel!
@IBOutlet var altitudeLabel: UILabel!
@IBOutlet var verticalAccuracyLabel: UILabel!
@IBOutlet var distanceTraveledLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
LocationManager.delegate = self
LocationManager.desiredAccuracy = kCLLocationAccuracyBest
LocationManager.requestAlwaysAuthorization()
}
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
print("Authorization Status Changed to \(status.rawValue)")
switch status {
case .Authorized, .AuthorizedWhenInUse:
LocationManager.startUpdatingLocation()
default:
LocationManager.stopUpdatingLocation()
}
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
let errorType = error.code == CLError.Denied.rawValue ? "Access Denied": "Error \(error.code)"
let alertController = UIAlertController(title: "Location Manager Error", message: errorType, preferredStyle: .Alert)
let okAction = UIAlertAction(title: "OK", style: .Cancel, handler: {action in})
alertController.addAction(okAction)
presentViewController(alertController, animated: true, completion: nil)
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let newLocation = (locations as [CLLocation]) [locations.count-1]
let latitudeString = String(format: "%g\u{00B0}", newLocation.coordinate.latitude)
latitudeLabel.text = latitudeString
let longitudeString = String(format: "%g\u{00B0}", newLocation.coordinate.longitude)
longitudeLabel.text = longitudeString
let horizontalAccuracyString = String(format: "%g\u{00B0}", newLocation.horizontalAccuracy)
horizontalAccuracy.text = horizontalAccuracyString
let altitudeString = String(format: "%g\u{00B0}", newLocation.altitude)
altitudeLabel.text = altitudeString
let verticalAccuracyString = String(format: "%g\u{00B0}", newLocation.verticalAccuracy)
verticalAccuracyLabel.text = verticalAccuracyString
if newLocation.horizontalAccuracy < 0 {
return
}
if newLocation.horizontalAccuracy > 100 ||
newLocation.verticalAccuracy > 50 {
return
}
if previousPoint == nil {
totalMovementDistance = 0
} else {
totalMovementDistance += newLocation.distanceFromLocation(previousPoint!)
}
previousPoint = newLocation
let distanceString = String(format: "%gm", totalMovementDistance)
distanceTraveledLabel.text = distanceString
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
This is my Info.plist file :

This is my simulator :

I want the output as follows:

2 . , .