Added WakeMethod differentiation

This commit is contained in:
Aaron
2021-01-20 11:23:50 -05:00
parent e0fd1e758d
commit 84e4358fbc
3 changed files with 115 additions and 77 deletions
@@ -11,11 +11,24 @@ import AVFoundation
class AlarmActivationViewController: UIViewController
{
var timer: Timer?
var currentAlarm: Alarm?
init?(coder: NSCoder, currentAlarm: Alarm)
{
self.currentAlarm = currentAlarm
//print(currentAlarm.wakeMethod)
super.init(coder: coder)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad()
{
super.viewDidLoad()
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
setAlarmType()
}
@objc func playSound()
@@ -23,4 +36,23 @@ class AlarmActivationViewController: UIViewController
AudioServicesPlayAlertSound(SystemSoundID(1005))
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
}
func setAlarmType()
{
if let alarm = currentAlarm
{
switch alarm.wakeMethod.name {
case "Walk":
walkAction()
case "Jump":
jumpAction()
case "Puzzle":
puzzleAction()
case "Smash":
print("")
default:
print("Invalid alarm type")
}
}
}
}