Last active
September 5, 2018 17:35
-
-
Save davidseek/d519a1025522f90dc25dae28e83841f9 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
| import Foundation | |
| import CoreLocation | |
| class LocationManager: NSObject { | |
| private let locationManager = CLLocationManager() | |
| override init() { | |
| super.init() | |
| self.locationManager.delegate = self | |
| self.locationManager.desiredAccuracy = kCLLocationAccuracyBest | |
| self.locationManager.requestWhenInUseAuthorization() | |
| } | |
| } | |
| // MARK: - Core Location Delegate | |
| extension LocationManager: CLLocationManagerDelegate { | |
| func locationManager(_ manager: CLLocationManager, | |
| didChangeAuthorization status: CLAuthorizationStatus) { | |
| switch status { | |
| case .notDetermined : print("notDetermined") // location permission not asked for yet | |
| case .authorizedWhenInUse : print("authorizedWhenInUse") // location authorized | |
| case .authorizedAlways : print("authorizedAlways") // location authorized | |
| case .restricted : print("restricted") // TODO: handle | |
| case .denied : print("denied") // TODO: handle | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment