diff --git a/ProjectClock/AlarmActivationViewController.swift b/ProjectClock/AlarmActivationViewController.swift index e1f5a64..54a7f7f 100644 --- a/ProjectClock/AlarmActivationViewController.swift +++ b/ProjectClock/AlarmActivationViewController.swift @@ -63,7 +63,7 @@ class AlarmActivationViewController: UIViewController @objc func playSound() { - AudioServicesPlayAlertSound(SystemSoundID(1005)) + AudioServicesPlayAlertSound(currentAlarm!.alarmTone) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) } diff --git a/ProjectClock/Models.swift b/ProjectClock/Models.swift index 458ef65..647770b 100644 --- a/ProjectClock/Models.swift +++ b/ProjectClock/Models.swift @@ -6,6 +6,7 @@ // import Foundation +import AVFoundation struct User: Codable { @@ -44,6 +45,7 @@ class Alarm: Codable var minute: Int var text: String var wakeMethod: WVM + var alarmTone: SystemSoundID /// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat) var repeats: [Bool] @@ -55,7 +57,8 @@ class Alarm: Codable init(enabled: Bool = true, hour: Int, minute: Int, text: String, wakeMethod: WVM, repeats: [Bool] = [false, true, true, true, true, true, false], - lastActivate: Date = Date() + lastActivate: Date = Date(), + alarmTone: SystemSoundID = SystemSoundID(1005) ) { self.enabled = enabled @@ -65,6 +68,7 @@ class Alarm: Codable self.wakeMethod = wakeMethod self.repeats = repeats self.lastActivate = lastActivate + self.alarmTone = alarmTone } /// Does it automatically disable after activating once