Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. var dateStamp = Date()
  2. var clientName = [""]
  3. var projecDescript = [""]
  4.  
  5. // Custom cell to make all input fields custom
  6. class CustomCell: UITableViewCell {
  7. //Make your outlets here, connect the outlets from cell in your storyboard
  8.  
  9. @IBOutlet var clientNameLabel: UILabel!
  10. @IBOutlet var descriptionLabel: UILabel!
  11. @IBOutlet var dateStamp: UILabel!
  12.  
  13. }
  14.  
  15. class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
  16.  
  17. @IBOutlet var clientTableList: UITableView!
  18.  
  19. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  20. return (clientName.count)
  21. return (projecDescript.count)
  22. }
  23.  
  24. // This is the new items added into the inputs
  25. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
  26. {
  27. let cell = tableView.dequeueReusableCell(withIdentifier: "clientCell", for: indexPath) as! CustomCell
  28.  
  29. // Adds Clients Name
  30. let companyName = clientName[indexPath.row]
  31. cell.clientNameLabel?.text = companyName
  32.  
  33. // Adds Clients Description
  34. let descriptionName = projecDescript[indexPath.row]
  35. cell.descriptionLabel?.text = descriptionName
  36.  
  37.  
  38.  
  39. return cell
  40. }
  41.  
  42. func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
  43. return true
  44. }
  45.  
  46. override func viewDidAppear(_ animated: Bool) {
  47. clientTableList.reloadData()
  48. }
  49.  
  50. import UIKit
  51.  
  52. class AddInvoice: UIViewController {
  53.  
  54. @IBOutlet var clientNameInput: UITextField!
  55. @IBOutlet var descriptionNameInput: UITextView!
  56.  
  57.  
  58.  
  59. @IBAction func addInvoice(_ sender: Any) {
  60.  
  61. if clientNameInput.text != "" && descriptionNameInput.text != ""
  62. {
  63. clientName.append(clientNameInput.text!)
  64. //clientInput.text = ""
  65.  
  66. projecDescript.append(descriptionNameInput.text!)
  67. //descriptionFieldInput.text = ""
  68.  
  69.  
  70. _ = navigationController?.popViewController(animated: true)
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement