Guest User

Untitled

a guest
Dec 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. // DetailView.swift
  2. // HomeMed
  3. //
  4. // Created by Joao Boavida on 10/12/2018.
  5. // Copyright © 2018 Joao Boavida. All rights reserved.
  6. //
  7.  
  8. import UIKit
  9.  
  10. class DetailView: UIViewController {
  11.  
  12. @IBOutlet var nameLbl: UILabel!
  13. @IBOutlet var subtextLbl: UILabel!
  14. @IBOutlet var expdateLbl: UILabel!
  15.  
  16. }
  17.  
  18. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  19.  
  20. let medicine = medArray[indexPath.row]
  21.  
  22. if let vc = storyboard?.instantiateViewController(withIdentifier: "DetailView") as? DetailView {
  23.  
  24. vc.nameLbl.text = medicine.name
  25.  
  26. if let subtext = medicine.subtext {
  27. vc.subtextLbl.text = subtext
  28. } else {
  29. vc.subtextLbl.text = ""
  30. }
  31.  
  32. let ISOdateFormatter = ISO8601DateFormatter()
  33. ISOdateFormatter.formatOptions = [.withMonth, .withYear, .withDashSeparatorInDate]
  34.  
  35. vc.expdateLbl.text = "Exp: (ISOdateFormatter.string(from: medicine.expiry))"
  36.  
  37. navigationController?.pushViewController(vc, animated: true)
  38.  
  39. }
  40.  
  41. }
Add Comment
Please, Sign In to add comment