|
29 | 29 |
|
30 | 30 | import UIKit |
31 | 31 |
|
32 | | -class GLTableCollectionViewController: UITableViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { |
33 | | - // This string constant will be the cellIdentifier for the UITableViewCells |
34 | | - // holding the UICollectionView, it's important to append "_section#" to it |
35 | | - // so we can understand which cell is the one we are looking for in the |
36 | | - // debugger. Look in UITableView's data source cellForRowAt method for more |
37 | | - // explanations about the UITableViewCell reuse handling. |
38 | | - let tableCellID: String = "tableViewCellID_section_#" |
39 | | - let collectionCellID: String = "collectionViewCellID" |
| 32 | +final class GLTableCollectionViewController: UITableViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { |
| 33 | + // This static string constant will be the cellIdentifier for the |
| 34 | + // UITableViewCells holding the UICollectionView, it's important to append |
| 35 | + // "_section#" to it so we can understand which cell is the one we are |
| 36 | + // looking for in the debugger. Look in UITableView's data source |
| 37 | + // cellForRowAt method for more explanations about the UITableViewCell reuse |
| 38 | + // handling. |
| 39 | + private static let tableCellID: String = "tableViewCellID_section_#" |
40 | 40 |
|
41 | | - let numberOfSections: Int = 20 |
42 | | - let numberOfCollectionsForRow: Int = 1 |
43 | | - let numberOfCollectionItems: Int = 20 |
| 41 | + private let numberOfSections: Int = 20 |
| 42 | + private let numberOfCollectionsForRow: Int = 1 |
| 43 | + private let numberOfCollectionItems: Int = 20 |
44 | 44 |
|
45 | | - var colorsDict: [Int: [UIColor]] = [:] |
| 45 | + private var colorsDict: [Int: [UIColor]] = [:] |
46 | 46 |
|
47 | 47 | /// Set true to enable UICollectionViews scroll pagination |
48 | | - var paginationEnabled: Bool = true |
| 48 | + private var paginationEnabled: Bool = true |
49 | 49 |
|
50 | 50 | override func viewDidLoad() { |
51 | 51 | super.viewDidLoad() |
@@ -109,10 +109,10 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa |
109 | 109 | // will have a different UICollectionView with UICollectionViewCells in |
110 | 110 | // it and UITableView reuse won't work as expected giving back wrong |
111 | 111 | // cells. |
112 | | - var cell: GLCollectionTableViewCell? = tableView.dequeueReusableCell(withIdentifier: tableCellID + indexPath.section.description) as? GLCollectionTableViewCell |
| 112 | + var cell: GLCollectionTableViewCell? = tableView.dequeueReusableCell(withIdentifier: GLTableCollectionViewController.tableCellID + indexPath.section.description) as? GLCollectionTableViewCell |
113 | 113 |
|
114 | 114 | if cell == nil { |
115 | | - cell = GLCollectionTableViewCell(style: .default, reuseIdentifier: tableCellID + indexPath.section.description) |
| 115 | + cell = GLCollectionTableViewCell(style: .default, reuseIdentifier: GLTableCollectionViewController.tableCellID + indexPath.section.description) |
116 | 116 |
|
117 | 117 | // Configure the cell... |
118 | 118 | cell!.selectionStyle = .none |
@@ -159,7 +159,7 @@ class GLTableCollectionViewController: UITableViewController, UICollectionViewDa |
159 | 159 | } |
160 | 160 |
|
161 | 161 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
162 | | - guard let cell: GLIndexedCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: collectionCellID, for: indexPath) as? GLIndexedCollectionViewCell else { |
| 162 | + guard let cell: GLIndexedCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: GLIndexedCollectionViewCell.identifier, for: indexPath) as? GLIndexedCollectionViewCell else { |
163 | 163 | fatalError("UICollectionViewCell must be of GLIndexedCollectionViewCell type") |
164 | 164 | } |
165 | 165 |
|
|
0 commit comments