|
|
@ -11,8 +11,6 @@ protocol LocationControllerDelegate: NSObject { |
|
|
|
|
|
|
|
|
|
|
|
class LocationController: NSObject { |
|
|
|
class LocationController: NSObject { |
|
|
|
private let store: DataStore |
|
|
|
private let store: DataStore |
|
|
|
private static var sharedController = LocationController(withStore: DataStore.shared()) |
|
|
|
|
|
|
|
weak var delegate: LocationControllerDelegate? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init(withStore dataStore: DataStore) { |
|
|
|
init(withStore dataStore: DataStore) { |
|
|
|
store = dataStore |
|
|
|
store = dataStore |
|
|
@ -25,10 +23,6 @@ class LocationController: NSObject { |
|
|
|
return locationManager |
|
|
|
return locationManager |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
class func shared() -> LocationController { |
|
|
|
|
|
|
|
return sharedController |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func authorizationStatus() -> CLAuthorizationStatus { |
|
|
|
func authorizationStatus() -> CLAuthorizationStatus { |
|
|
|
return CLLocationManager.authorizationStatus() |
|
|
|
return CLLocationManager.authorizationStatus() |
|
|
|
} |
|
|
|
} |
|
|
@ -61,9 +55,7 @@ class LocationController: NSObject { |
|
|
|
case .authorizedAlways: |
|
|
|
case .authorizedAlways: |
|
|
|
locationManager.startUpdatingLocation() |
|
|
|
locationManager.startUpdatingLocation() |
|
|
|
case .notDetermined: |
|
|
|
case .notDetermined: |
|
|
|
if #available(macOS 10.15, *) { |
|
|
|
locationManager.startUpdatingLocation() |
|
|
|
locationManager.requestWhenInUseAuthorization() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case .denied, .restricted: |
|
|
|
case .denied, .restricted: |
|
|
|
locationManager.startUpdatingLocation() |
|
|
|
locationManager.startUpdatingLocation() |
|
|
|
default: |
|
|
|
default: |
|
|
|