Skip to content

#: fixed conditional binding #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions LocationKit/LocationDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
}
Expand All @@ -175,7 +175,7 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate {
}
}

private func checkStates() -> UIApplicationState {
private func checkStates() -> UIApplication.State {
return UIApplication.shared.applicationState
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions LocationKit/LocationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -187,6 +187,6 @@ public class LocationManager: NSObject {

internal func endBackgroundTask() {
UIApplication.shared.endBackgroundTask(backgroundTask)
backgroundTask = UIBackgroundTaskInvalid
backgroundTask = UIBackgroundTaskIdentifier.invalid
}
}