[+] Add comments for table data source
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user