@@ -22,32 +22,48 @@ class CheckRoutineTableViewController: UITableViewController {
22
22
23
23
24
24
// MARK: - CheckRoutineTableViewController UITableViewDelegate Methods
25
-
25
+ override func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
26
+
27
+ // Toggles cell accessoryType from checkmark to none
28
+ // Maybe refactor and have a custom accessoryType
29
+ if let cell = tableView. cellForRow ( at: indexPath) {
30
+ if cell. accessoryType == . checkmark{
31
+ cell. accessoryType = . none
32
+ } else {
33
+ cell. accessoryType = . checkmark
34
+ }
35
+ }
36
+
37
+ tableView. deselectRow ( at: indexPath, animated: true )
38
+ }
26
39
27
40
28
41
// MARK: - CheckRoutineTableViewController UITableViewDataSource Methods
29
42
30
43
override func tableView( _ tableView: UITableView , numberOfRowsInSection section: Int ) -> Int {
31
44
32
- return 1
45
+ return 5
33
46
}
34
47
35
48
override func tableView( _ tableView: UITableView , cellForRowAt indexPath: IndexPath ) -> UITableViewCell {
36
49
37
50
let cell : UITableViewCell = tableView. dequeueReusableCell ( withIdentifier: " CheckroutineItem " , for: indexPath)
38
51
39
- return cell
52
+ let label = cell. viewWithTag ( 100 ) as! UILabel
53
+
54
+ if indexPath. row == 0 {
55
+ label. text = " I am the man "
56
+ } else if indexPath. row == 1 {
57
+ label. text = " Who provides "
58
+ } else if indexPath. row == 2 {
59
+ label. text = " CAN you see me? "
60
+ }
61
+
62
+
63
+
64
+ return cell
40
65
}
41
66
42
67
}
43
- //
44
- //extension CheckRoutineTableViewController: UITableViewDelegate{
45
- //
46
- //
47
- //}
48
- //
49
- //extension CheckRoutineTableViewController: UITableViewDataSource{
50
- //
51
- //
52
- //}
68
+
53
69
0 commit comments