Skip to content

Instantly share code, notes, and snippets.

@TungVuDuc2805
Created June 7, 2020 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TungVuDuc2805/c6bf84b1630981255f959e938f289eb5 to your computer and use it in GitHub Desktop.
Save TungVuDuc2805/c6bf84b1630981255f959e938f289eb5 to your computer and use it in GitHub Desktop.
class ProfileViewModel: NSObject, UITableViewDataSource {
var items: [ProfileSectionControllerProtocol] = []
func numberOfSections(in tableView: UITableView) -> Int {
return items.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items[section].rowCount
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let sectionController = items[indexPath.section]
let cellController = sectionController.cells[indexPath.row]
return cellController.view(tableView)
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return items[section].title
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment