Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement