Showing
1 changed file
with
10 additions
and
0 deletions
| ... | @@ -59,7 +59,13 @@ public class swiftApi { | ... | @@ -59,7 +59,13 @@ public class swiftApi { |
| 59 | 59 | ||
| 60 | func startTrackingCallback(_ steps: NSNumber?) -> Void { | 60 | func startTrackingCallback(_ steps: NSNumber?) -> Void { |
| 61 | 61 | ||
| 62 | + print("=== steps ===") | ||
| 63 | + print(steps as? Int ?? 0) | ||
| 64 | + | ||
| 62 | if (steps != nil) { | 65 | if (steps != nil) { |
| 66 | + print("=== steps to save ===") | ||
| 67 | + | ||
| 68 | + print((steps as! Int) - GlobalVariables.savedSteps) | ||
| 63 | swiftApi().setSteps((steps as! Int) - GlobalVariables.savedSteps) | 69 | swiftApi().setSteps((steps as! Int) - GlobalVariables.savedSteps) |
| 64 | } | 70 | } |
| 65 | 71 | ||
| ... | @@ -97,11 +103,14 @@ public class swiftApi { | ... | @@ -97,11 +103,14 @@ public class swiftApi { |
| 97 | } | 103 | } |
| 98 | 104 | ||
| 99 | func startTimer() { | 105 | func startTimer() { |
| 106 | + print("========= Timer Started! =========") | ||
| 107 | + | ||
| 100 | let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".timer") | 108 | let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".timer") |
| 101 | timer = DispatchSource.makeTimerSource(queue: queue) | 109 | timer = DispatchSource.makeTimerSource(queue: queue) |
| 102 | timer!.schedule(deadline: .now(), repeating: .seconds(10)) | 110 | timer!.schedule(deadline: .now(), repeating: .seconds(10)) |
| 103 | timer!.setEventHandler { [weak self] in | 111 | timer!.setEventHandler { [weak self] in |
| 104 | // do whatever stuff you want on the background queue here here | 112 | // do whatever stuff you want on the background queue here here |
| 113 | + print("========= interval! =========") | ||
| 105 | 114 | ||
| 106 | let persistedSteps = swiftApi().getSteps() | 115 | let persistedSteps = swiftApi().getSteps() |
| 107 | if (persistedSteps > 0) { | 116 | if (persistedSteps > 0) { |
| ... | @@ -132,6 +141,7 @@ public class swiftApi { | ... | @@ -132,6 +141,7 @@ public class swiftApi { |
| 132 | } | 141 | } |
| 133 | 142 | ||
| 134 | func stopTimer() { | 143 | func stopTimer() { |
| 144 | + print("========= Timer Stopped! =========") | ||
| 135 | timer?.cancel() | 145 | timer?.cancel() |
| 136 | timer = nil | 146 | timer = nil |
| 137 | } | 147 | } | ... | ... |
-
Please register or login to post a comment