[+] Create AlarmDetector

This commit is contained in:
Hykilpikonna
2021-01-17 10:32:23 -05:00
parent cb5515e54a
commit 30756d32aa
2 changed files with 50 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
//
// AlarmActivator.swift
// ProjectClock
//
// Created by Hykilpikonna on 1/17/21.
//
import Foundation
/**
Class to activate alarms when the user is inside the app
*/
class AlarmActivator
{
/// Interval in seconds
static var interval = 1
/// Timer for scheduled calls
var timer: Timer?
/**
Start detecting alarms
*/
func start()
{
if timer != nil { return }
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(AlarmActivator.check), userInfo: nil, repeats: true)
}
/**
Stop detecting alarms
*/
func stop()
{
timer?.invalidate()
timer = nil
}
/**
Check alarm
*/
@objc func check()
{
NSLog("Check")
}
}