Skip to content

Instantly share code, notes, and snippets.

@meyusufdemirci
Created January 23, 2019 10:29
Show Gist options
  • Save meyusufdemirci/ae01adc5951387aacdb44af8dfd8fc7b to your computer and use it in GitHub Desktop.
Save meyusufdemirci/ae01adc5951387aacdb44af8dfd8fc7b to your computer and use it in GitHub Desktop.
class HomeTableController: UITableViewController {
var presenter: HomePresenterProtocol!
var contactList: [Contact] = []
override func viewDidLoad() {
super.viewDidLoad()
presenter.getContact()
}
}
extension HomeTableController: HomeViewProtocol {
func showContact(contact: [Contact]) {
self.contactList = contact
tableView.reloadData()
}
}
extension HomeTableController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contactList.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
let contact = contactList[indexPath.row]
cell.textLabel?.text = "\(contact.fullname) - \(contact.gsm)"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment