Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. func startUpdatingLocation() {
  2. self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
  3. self.locationManager.activityType = .fitness
  4. self.locationManager.startUpdatingLocation()
  5. }
  6.  
  7. extension ViewController: CLLocationManagerDelegate {
  8. func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
  9. if status == .authorizedWhenInUse {
  10. self.startUpdatingLocation()
  11. }
  12. }
  13.  
  14. func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
  15. guard let location = locations.last else {
  16. return
  17. }
  18. DispatchQueue.main.async {
  19. self.accuracyLabel.text = "\(location.horizontalAccuracy)"
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement