From 117de7ea209c4e27124daf4d70e47ca84a01aa9f Mon Sep 17 00:00:00 2001 From: Evgeniy Orlov Date: Tue, 27 Jul 2021 13:09:36 +0600 Subject: [PATCH 1/2] #: fixed conditional binding --- LocationKit/LocationDetection.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LocationKit/LocationDetection.swift b/LocationKit/LocationDetection.swift index 57eb584..97caf52 100644 --- a/LocationKit/LocationDetection.swift +++ b/LocationKit/LocationDetection.swift @@ -137,8 +137,8 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } else { let components = cal.dateComponents(unit, from: item.insideDatetime, to: nowDate!) item.insideDatetime = nowDate - guard let sec: Int = components.second! - 1 else { return -1 } - return sec + guard let sec = components.second else { return -1 } + return sec - 1 } case .outside: if item.insideDatetime == nil { @@ -147,8 +147,8 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } else { let components = cal.dateComponents(unit, from: item.insideDatetime, to: nowDate!) item.outsideDatetime = nowDate - guard let sec: Int = components.second! - 1 else { return -1 } - return sec + guard let sec = components.second else { return -1 } + return sec - 1 } } } From cad12363749f3f786bbee047ff8f600cab71978c Mon Sep 17 00:00:00 2001 From: Evgeniy Orlov Date: Fri, 22 Oct 2021 15:22:45 +0600 Subject: [PATCH 2/2] #: update syntax --- LocationKit/LocationDetection.swift | 6 +++--- LocationKit/LocationManager.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LocationKit/LocationDetection.swift b/LocationKit/LocationDetection.swift index 97caf52..21d579e 100644 --- a/LocationKit/LocationDetection.swift +++ b/LocationKit/LocationDetection.swift @@ -175,7 +175,7 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } } - private func checkStates() -> UIApplicationState { + private func checkStates() -> UIApplication.State { return UIApplication.shared.applicationState } @@ -335,13 +335,13 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { switch status { case .authorizedAlways: detectionItem.access = .requestAlwaysAuthorization - if selfManager.backgroundTask == UIBackgroundTaskInvalid { + if selfManager.backgroundTask == UIBackgroundTaskIdentifier.invalid { selfManager.startBackgroundTask() } break case .authorizedWhenInUse: detectionItem.access = .requestWhenInUseAuthorization - if selfManager.backgroundTask != UIBackgroundTaskInvalid { + if selfManager.backgroundTask != UIBackgroundTaskIdentifier.invalid { selfManager.endBackgroundTask() } break diff --git a/LocationKit/LocationManager.swift b/LocationKit/LocationManager.swift index 192d25f..2c25d59 100644 --- a/LocationKit/LocationManager.swift +++ b/LocationKit/LocationManager.swift @@ -12,7 +12,7 @@ import CoreLocation public class LocationManager: NSObject { var regionDetectionList: [DetectionInfo] = [] open var requestAccess: RequestAccess = .requestAlwaysAuthorization - var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid + var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid public override init () { //print("LocationKit has been initialised") @@ -187,6 +187,6 @@ public class LocationManager: NSObject { internal func endBackgroundTask() { UIApplication.shared.endBackgroundTask(backgroundTask) - backgroundTask = UIBackgroundTaskInvalid + backgroundTask = UIBackgroundTaskIdentifier.invalid } }