-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathTableViewController.swift
More file actions
31 lines (24 loc) · 885 Bytes
/
TableViewController.swift
File metadata and controls
31 lines (24 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// TableViewController.swift
// Changeset
//
import UIKit
import Changeset
class TableViewController: UITableViewController {
fileprivate var dataSource = DataSource()
@IBAction func test(_ sender: UIBarButtonItem) {
self.dataSource.runTests() { (edits: Array<Changeset<String>.Edit>, isComplete: Bool) in
self.tableView.update(with: edits)
sender.isEnabled = isComplete
}
}
// MARK: - UITableViewDataSource
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.dataSource.numberOfElementsInSection(section)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = self.dataSource.textForElementAtIndexPath(indexPath)
return cell
}
}