diff --git a/ProjectClock/AlarmViewController.swift b/ProjectClock/AlarmViewController.swift index 433c105..d8386d1 100644 --- a/ProjectClock/AlarmViewController.swift +++ b/ProjectClock/AlarmViewController.swift @@ -23,7 +23,7 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource func numberOfSections(in: UITableView) -> Int { return 1 } /// How many rows are there - func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return getLocalAlarms().count } + func tableView(_ v: UITableView, numberOfRowsInSection s: Int) -> Int { return Alarms.fromLocal().list.count } /// Configure each cell func tableView(_ v: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell @@ -31,7 +31,7 @@ extension AlarmViewController: UITableViewDelegate, UITableViewDataSource // Get the cell and item at index i let rawCell = v.dequeueReusableCell(withIdentifier: "alarm", for: i) guard let cell = rawCell as? AlarmTableCell else { return rawCell } - let item = getLocalAlarms()[i.row] + let item = Alarms.fromLocal().list[i.row] // Set the content of the cell to the content of the item. cell.setData(item) diff --git a/ProjectClock/Net.swift b/ProjectClock/Net.swift index 0b7027f..9fad282 100644 --- a/ProjectClock/Net.swift +++ b/ProjectClock/Net.swift @@ -30,9 +30,6 @@ class JSON /// Local storage let localStorage = UserDefaults(suiteName: "group.org.hydev.alarm.clock")! -/// Get alarms from local storage -func getLocalAlarms() -> [Alarm] { return JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!)! } - /// API class struct API {