Skip to content

Instantly share code, notes, and snippets.

@anuragajwani
Created May 6, 2017 19:16
Show Gist options
  • Save anuragajwani/aa0edafcd77f5e9980806590e3026eac to your computer and use it in GitHub Desktop.
Save anuragajwani/aa0edafcd77f5e9980806590e3026eac to your computer and use it in GitHub Desktop.
import Foundation
import UIKit
final class MoviesTableViewDataSource: NSObject, UITableViewDataSource {
var viewModels: [MovieCellViewModel] = []
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.viewModels.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellViewModel = viewModels[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "MovieCell")!
cell.textLabel?.text = cellViewModel.textLabel
cell.detailTextLabel?.text = cellViewModel.detailTextLabel
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment