[+] Create AlarmDetector
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
4F8A607125A9160400D88DC3 /* AddAlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */; };
|
||||
4F98955225A9260400F51321 /* Net.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F98955125A9260400F51321 /* Net.swift */; };
|
||||
4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */; };
|
||||
4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD642D225B48C380069171E /* AlarmActivator.swift */; };
|
||||
4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0683E25A5F18700304E6B /* AppDelegate.swift */; };
|
||||
4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684025A5F18700304E6B /* SceneDelegate.swift */; };
|
||||
4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* AccountViewController.swift */; };
|
||||
@@ -27,6 +28,7 @@
|
||||
4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAlarmViewController.swift; sourceTree = "<group>"; };
|
||||
4F98955125A9260400F51321 /* Net.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Net.swift; sourceTree = "<group>"; };
|
||||
4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmViewController.swift; sourceTree = "<group>"; };
|
||||
4FD642D225B48C380069171E /* AlarmActivator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmActivator.swift; sourceTree = "<group>"; };
|
||||
4FF0683B25A5F18700304E6B /* ProjectClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectClock.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4FF0683E25A5F18700304E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
4FF0684025A5F18700304E6B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -88,6 +90,7 @@
|
||||
7C5DAE9B25AF812200E44C52 /* clock.png */,
|
||||
4F509BD125AE22D100726227 /* Models.swift */,
|
||||
7C83963825AF68980027A94C /* TestingViewController.swift */,
|
||||
4FD642D225B48C380069171E /* AlarmActivator.swift */,
|
||||
);
|
||||
path = ProjectClock;
|
||||
sourceTree = "<group>";
|
||||
@@ -179,6 +182,7 @@
|
||||
7C83963925AF68980027A94C /* TestingViewController.swift in Sources */,
|
||||
4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */,
|
||||
4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */,
|
||||
4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */,
|
||||
4FF0684125A5F18700304E6B /* SceneDelegate.swift in Sources */,
|
||||
4FA419AF25AF93EC004CE0FC /* AlarmViewController.swift in Sources */,
|
||||
4F509BD225AE22D100726227 /* Models.swift in Sources */,
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user