diff --git a/ProjectClock/AddAlarmViewController.swift b/ProjectClock/AddAlarmViewController.swift index e46da33..e92d760 100644 --- a/ProjectClock/AddAlarmViewController.swift +++ b/ProjectClock/AddAlarmViewController.swift @@ -62,6 +62,15 @@ class AddAlarmViewController: EndEditingOnReturn } } } + + //Sets alarm tone + if let toneName = alarmCell.toneLabel.text { + for index in 0...ringtones.count-1 { + if toneName == ringtones[index].name { + ringtonePicker.selectRow(index, inComponent: 0, animated: true) + } + } + } } } diff --git a/ProjectClock/AlarmViewController.swift b/ProjectClock/AlarmViewController.swift index b21a6e2..64090eb 100644 --- a/ProjectClock/AlarmViewController.swift +++ b/ProjectClock/AlarmViewController.swift @@ -77,7 +77,7 @@ class AlarmTableCell: UITableViewCell @IBOutlet weak var repeatText: UILabel! @IBOutlet weak var goingOffText: UILabel! @IBOutlet weak var wvmText: UILabel! - + @IBOutlet weak var toneLabel: UILabel! var alarm: Alarm! @@ -90,6 +90,7 @@ class AlarmTableCell: UITableViewCell descriptionText.text = "- " + alarm.text enable.isOn = alarm.enabled wvmText.text = alarm.wakeMethod.name + toneLabel.text = alarm.toneName // Display Hour, Minute, and AM or PM ampm.text = alarm.hour < 12 || alarm.hour == 24 ? "AM" : "PM" diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index 42d14d2..b62855a 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -83,6 +83,13 @@ + @@ -109,6 +116,7 @@ + @@ -942,7 +950,7 @@ - + diff --git a/ProjectClock/Models.swift b/ProjectClock/Models.swift index 3741d06..562c376 100644 --- a/ProjectClock/Models.swift +++ b/ProjectClock/Models.swift @@ -84,6 +84,7 @@ class Alarm: Codable, Equatable var wakeMethod: WVM var alarmTone: SystemSoundID var notificationID: String + var toneName: String /// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat) var repeats: [Bool] @@ -96,7 +97,8 @@ class Alarm: Codable, Equatable hour: Int, minute: Int, text: String, wakeMethod: WVM, repeats: [Bool] = [false, true, true, true, true, true, false], lastActivate: Date = Date(), - alarmTone: SystemSoundID = ringtones[0].tone + alarmTone: SystemSoundID = ringtones[0].tone, + toneName: String = "" ) { @@ -109,6 +111,7 @@ class Alarm: Codable, Equatable self.lastActivate = lastActivate self.alarmTone = alarmTone self.notificationID = "notification.id.\(Int.random(in: 1...Int.max))" + self.toneName = toneName } /// Does it automatically disable after activating once