[F] Refresh table when alarms are changed

This commit is contained in:
Hykilpikonna
2021-01-17 17:10:58 -05:00
parent a57ab9c2f8
commit 26752f607e
2 changed files with 9 additions and 1 deletions
+2
View File
@@ -3,12 +3,14 @@ import UIKit
class AlarmViewController: UIViewController
{
@IBOutlet weak var table: UITableView!
static var staticTable: UITableView?
override func viewDidLoad()
{
super.viewDidLoad()
// Assign table delegate and data source
AlarmViewController.staticTable = table
table.delegate = self
table.dataSource = self
}
+7 -1
View File
@@ -100,7 +100,13 @@ class Alarms: Codable
var list: [Alarm] = []
/// Save alarms to local storage
func localSave() { localStorage.setValue(JSON.stringify(list)!, forKey: "alarms") }
func localSave()
{
localStorage.setValue(JSON.stringify(list)!, forKey: "alarms")
// Reload table view
if let table = AlarmViewController.staticTable { table.reloadData() }
}
/// Read alarms from local storage
func localRead() { list = JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!)! }