[+] Add comments for table data source

This commit is contained in:
Hykilpikonna
2021-01-24 09:10:59 -05:00
parent 52d5691b5b
commit 6df3790e51
+26 -11
View File
@@ -90,24 +90,39 @@ class StopwatchViewController: UIViewController {
} }
} }
extension StopwatchViewController: UITableViewDelegate, UITableViewDataSource { /**
Table data source
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { */
extension StopwatchViewController: UITableViewDelegate, UITableViewDataSource
{
/**
Define row count
*/
func tableView(_ _: UITableView, numberOfRowsInSection _: Int) -> Int
{
return lappedTimes.count return lappedTimes.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { /**
let cell = tableView.dequeueReusableCell(withIdentifier: "lapCell", for: indexPath) Set cell at i
cell.textLabel?.text = lappedTimes[indexPath.row] */
func tableView(_ view: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell
{
let cell = view.dequeueReusableCell(withIdentifier: "lapCell", for: i)
cell.textLabel?.text = lappedTimes[i.row]
cell.selectionStyle = .none cell.selectionStyle = .none
return cell return cell
} }
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { /**
if editingStyle == .delete { Swipe left to delete cells at i
lappedTimes.remove(at: indexPath.row) */
func tableView(_ view: UITableView, commit: UITableViewCell.EditingStyle, forRowAt i: IndexPath)
tableView.deleteRows(at: [indexPath], with: .automatic) {
if commit == .delete
{
lappedTimes.remove(at: i.row)
view.deleteRows(at: [i], with: .automatic)
} }
} }
} }