Last active
April 13, 2019 20:45
-
-
Save paulw11/ea199a76b8e624ebb2ff3d809f022b13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func startUpdatingLocation() { | |
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest | |
self.locationManager.activityType = .fitness | |
self.locationManager.startUpdatingLocation() | |
} | |
extension ViewController: CLLocationManagerDelegate { | |
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { | |
if status == .authorizedWhenInUse { | |
self.startUpdatingLocation() | |
} | |
} | |
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | |
guard let location = locations.last else { | |
return | |
} | |
DispatchQueue.main.async { | |
self.accuracyLabel.text = "\(location.horizontalAccuracy)" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment