Add some documentation
Seto Elkahfi committed
May 16, 2017 at 09:48 UTC
c3baee5a2c8300708083fb86b9fbb039fb35ded0
3 files changed
+21
-3
Example/Tests/Tests.swift
+7
-3
@@ -1,12 +1,16 @@
1
import UIKit
2
import XCTest
3
import JomloTableView
4
+@testable
5
+import Pods_JomloTableView_Example
6
7
class Tests: XCTestCase {
8
9
override func setUp() {
10
super.setUp()
11
// Put setup code here. This method is called before the invocation of each test method in the class.
12
+
13
+
14
}
15
16
override func tearDown() {
@@ -14,9 +18,9 @@ class Tests: XCTestCase {
18
super.tearDown()
19
}
20
17
- func testExample() {
18
- // This is an example of a functional test case.
19
- XCTAssert(true, "Pass")
21
+ func testAddRowToSection() {
22
+ let jomloTableSection = JomloTableViewSection()
23
+ XCTAssertEqual(jomloTableSection.count, 0)
24
}
25
26
func testPerformanceExample() {
JomloTableView/Classes/JomloTableView.swift
+10
@@ -8,6 +8,12 @@
8
9
import Foundation
10
11
+/**
12
+ This main class is basically a subclass from UITableView with sections array to hold row(s).
13
+ This table view directly conform to UITableViewDelegate and UITableViewDataSource, makes your
14
+ view controller that use table view free from conforming these two protocols.
15
+
16
+ */
17
public class JomloTableView: UITableView {
18
19
// Table view section
@@ -40,6 +46,8 @@ public class JomloTableView: UITableView {
46
47
extension JomloTableView: UITableViewDelegate {
48
49
+ // MARK: - UITableViewDelegate delegate extension
50
+
51
public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
52
return sections[indexPath.section].rows[indexPath.row].estimatedRowHeight
53
}
@@ -61,6 +69,8 @@ extension JomloTableView: UITableViewDelegate {
69
70
extension JomloTableView: UITableViewDataSource {
71
72
+ // MARK: - UITableViewDataSource delegate extension
73
+
74
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
75
if sections.count > 0 {
76
return sections[section].count
JomloTableView/Classes/JomloTableViewRow.swift
+4
@@ -8,6 +8,10 @@
8
9
import Foundation
10
11
+/**
12
+ A singe row to be inserted in an instance of JomloTableViewSection. Subclass from this class and reference the identifier
13
+ that used by its corresponding cell view. The cell is a subclass from JomloTableViewCell.
14
+ */
15
open class JomloTableViewRow: NSObject {
16
17
// Callback for on row clicked.