Hi,
I am really sorry but the more I read the chapters the more confused I am getting, now when I read Chapter 10, and try and find out what is M and what is V and what is C in the below code , I have no idea and I do not know why the same method with different arguments is being called again and again , please guide… the code is below —
import UIKit
class ChecklistViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
// MARK:- Table View Data Source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Checklistitem", for: indexPath)
let label = cell.viewWithTag(1000) as! UILabel
if indexPath.row % 5 == 0 {
label.text = "Walk the dog"
} else if indexPath.row % 5 == 1 {
label.text = "Brush my teeth"
} else if indexPath.row % 5 == 2 {
label.text = "Learn iOS development"
} else if indexPath.row % 5 == 3 {
label.text = "Soccer practice"
} else if indexPath.row % 5 == 4 {
label.text = "Eat ice cream"
}
return cell
}
// MARK:- Table View Delegate
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let cell = tableView.cellForRow(at: indexPath) {
if cell.accessoryType == .none {
cell.accessoryType = .checkmark
}
else {
cell.accessoryType = .none
}
}
tableView.deselectRow(at: indexPath, animated: true)
}
}