daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class HomeTableController: UITableViewController {
  2.     var presenter: HomePresenterProtocol!
  3.    
  4.     var contactList: [Contact] = []
  5.    
  6.     override func viewDidLoad() {
  7.         super.viewDidLoad()
  8.        
  9.         presenter.getContact()
  10.     }
  11. }
  12.  
  13. extension HomeTableController: HomeViewProtocol {
  14.     func showContact(contact: [Contact]) {
  15.         self.contactList = contact
  16.         tableView.reloadData()
  17.     }
  18. }
  19.  
  20. extension HomeTableController {
  21.     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  22.         return contactList.count
  23.     }
  24.    
  25.     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  26.         let cell = UITableViewCell()
  27.         let contact = contactList[indexPath.row]
  28.         cell.textLabel?.text = "\(contact.fullname) - \(contact.gsm)"
  29.         return cell
  30.     }
  31.    
  32.     override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  33.         tableView.deselectRow(at: indexPath, animated: true)
  34.        
  35.         presenter.showContactDetail(contact: contactList[indexPath.row])
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top