initial updates to the view controller

This commit is contained in:
Dallon Archibald
2021-01-13 13:43:39 -05:00
parent ca9cd23793
commit 785925e8ea
+36 -1
View File
@@ -9,11 +9,46 @@ import UIKit
class ViewController: UIViewController {
@IBOutlet var table: UITableView!
var models = [MyAlarm]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
table.delegate = self
table.dataSource = self
}
}
extension ViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}
extension ViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return models.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = models[indexPath.row].title
return cell
}
}
struct MyAlarm {
let title: String
let date: Date
let identifier: String
}