Skip to content

Instantly share code, notes, and snippets.

@dmlebron
Created July 2, 2018 22:09
Show Gist options
  • Save dmlebron/deb29863763139e2fe7faed1d1da2c69 to your computer and use it in GitHub Desktop.
Save dmlebron/deb29863763139e2fe7faed1d1da2c69 to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
let viewModel = ViewModel()
var jobs = [Job]()
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
viewModel.getJobs(closure: { (result) in
})
}
}
extension ViewController: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return jobs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel?.text = jobs[indexPath.row].company
cell.detailTextLabel?.text = "Location: \(jobs[indexPath.row].location ?? "N/A")"
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment