// // TableViewController.swift // Guibe // // Created by Max Hunt on 31/05/2019. // Copyright © 2019 8. All rights reserved. // import UIKit import MapKit class TableViewController: UIViewController { let appDelegate = UIApplication.shared.delegate as! AppDelegate var searchResults: [MKMapItem]? override func viewDidLoad() { super.viewDidLoad() // let testData = appDelegate.navigationResults // Do any additional setup after loading the view. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ } extension TableViewController: UITableViewDataSource, UITableViewDelegate { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.searchResults?.count ?? 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? TableViewCell let row = indexPath.row if let item = searchResults?[row] { cell?.cellLbl.text = item.name // cell.phoneLabel.text = item.phoneNumber } // cell?.cellLbl.text = self.searchResults[indexPath.row] // cell?.cellDelegate = self // cell?.index = indexPath return cell! } } extension TableViewController: tableViewProtocol { func onClickCell(index: Int) { debugPrint("Pressed on cell number \(index)") } }