SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top