Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
TableViewDataSource in SourcesTableViewController
class SourcesTableViewController : UITableViewController {
private var webservice :Webservice!
private var sourceListViewModel :SourceListViewModel!
private var dataSource :TableViewDataSource<SourceTableViewCell,SourceViewModel>!
override func viewDidLoad() {
super.viewDidLoad()
updateUI()
}
private func updateUI() {
self.webservice = Webservice()
self.sourceListViewModel = SourceListViewModel(webservice: self.webservice)
// setting up the bindings
self.sourceListViewModel.bindToSourceViewModels = {
self.updateDataSource()
}
}
private func updateDataSource() {
self.dataSource = TableViewDataSource(cellIdentifier: Cells.source, items: self.sourceListViewModel.sourceViewModels) { cell, vm in
cell.nameLabel.text = vm.name
cell.descriptionLabel.text = vm.body
}
self.tableView.dataSource = self.dataSource
self.tableView.reloadData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment