Made alarmTone editable, but localRead() nil error.

This commit is contained in:
Aaron
2021-01-27 22:44:16 -05:00
parent 240e23743b
commit 83d304e215
4 changed files with 24 additions and 3 deletions
@@ -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)
}
}
}
}
}
+2 -1
View File
@@ -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"
+9 -1
View File
@@ -83,6 +83,13 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mQf-S4-pMF">
<rect key="frame" x="225" y="19" width="0.0" height="0.0"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="dWq-jh-9Ue" firstAttribute="baseline" secondItem="4hj-fb-FF3" secondAttribute="baseline" id="4H2-o6-GfV"/>
@@ -109,6 +116,7 @@
<outlet property="goingOffText" destination="EPJ-eL-Kek" id="QNo-WD-AyS"/>
<outlet property="repeatText" destination="YhV-X3-y1v" id="Alj-Ko-6y6"/>
<outlet property="time" destination="mjO-SX-f31" id="OQC-eJ-Qjc"/>
<outlet property="toneLabel" destination="mQf-S4-pMF" id="gw1-8p-j1O"/>
<outlet property="wvmText" destination="Kaa-5k-xfL" id="gsX-DJ-xmb"/>
<segue destination="Mki-dC-5Kc" kind="show" identifier="edit-alarm" id="WYD-ju-WX0"/>
</connections>
@@ -942,7 +950,7 @@
<rect key="frame" x="0.0" y="0.0" width="374" height="170"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="person.crop.circle.badge.checkmark" catalog="system" translatesAutoresizingMaskIntoConstraints="NO" id="yVW-fL-SIQ">
<rect key="frame" x="130.5" y="0.0" width="111.5" height="109.5"/>
<rect key="frame" x="132" y="0.0" width="110" height="109.5"/>
<constraints>
<constraint firstAttribute="width" constant="110" id="So8-k5-nLS"/>
<constraint firstAttribute="height" constant="110" id="inA-vb-CrL"/>
+4 -1
View File
@@ -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