[F] Refresh table when alarms are changed
This commit is contained in:
@@ -3,12 +3,14 @@ import UIKit
|
|||||||
class AlarmViewController: UIViewController
|
class AlarmViewController: UIViewController
|
||||||
{
|
{
|
||||||
@IBOutlet weak var table: UITableView!
|
@IBOutlet weak var table: UITableView!
|
||||||
|
static var staticTable: UITableView?
|
||||||
|
|
||||||
override func viewDidLoad()
|
override func viewDidLoad()
|
||||||
{
|
{
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
// Assign table delegate and data source
|
// Assign table delegate and data source
|
||||||
|
AlarmViewController.staticTable = table
|
||||||
table.delegate = self
|
table.delegate = self
|
||||||
table.dataSource = self
|
table.dataSource = self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,13 @@ class Alarms: Codable
|
|||||||
var list: [Alarm] = []
|
var list: [Alarm] = []
|
||||||
|
|
||||||
/// Save alarms to local storage
|
/// 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
|
/// Read alarms from local storage
|
||||||
func localRead() { list = JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!)! }
|
func localRead() { list = JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!)! }
|
||||||
|
|||||||
Reference in New Issue
Block a user