Created
October 1, 2019 07:09
-
-
Save gwennguihal/13c5762b4ad27a3787fbeab83592ab40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DataSource: NSObject { | |
| public var sections = [Section]() | |
| } | |
| extension DataSource: UITableViewDataSource { | |
| public func numberOfSections(in tableView: UITableView) -> Int { | |
| return sections.count | |
| } | |
| public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| let section = sections[section] | |
| return section.cells.count | |
| } | |
| public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let section = sections[indexPath.section] | |
| guard let cell = section.cells[indexPath.item] else { | |
| fatalError() | |
| } | |
| guard let uiCell = tableView.dequeueReusableCell(withIdentifier: cell.identifier, for: indexPath) as? UICell else { | |
| fatalError() | |
| } | |
| uiCell.update(adapter: cell.getAdapter()) | |
| return uiCell | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment