Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. @IBOutlet weak var table: UITableView!
  2. @IBOutlet weak var addItemBtnOutlet: UIButton!
  3. @IBOutlet weak var addItemTextField: UITextField!
  4.  
  5. @IBAction func addItem(_ sender: Any) {
  6.  
  7. if let textFieldInput = addItemTextField.text {
  8.  
  9. items.addItem(text: textFieldInput)
  10. print(textFieldInput)
  11.  
  12. addItemTextField.text = ""
  13.  
  14.  
  15. table.reloadData()
  16. }
  17.  
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. // Return the number of rows for the table.
  25. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  26.  
  27. //returns number of items in Array
  28. return items.itemArray.count
  29. }
  30.  
  31. // Provide a cell object for each row.
  32. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  33.  
  34. let itemString = items.itemArray[indexPath.row]
  35.  
  36. // Fetch a cell of the appropriate type.
  37. let cell = tableView.dequeueReusableCell(withIdentifier: "TextInputCell", for: indexPath) as! TextInputTableViewCell
  38. // Configure the cell’s contents.
  39. //cell.clipsToBounds = true
  40. cell.configure(text: itemString, placeholder: "")
  41.  
  42.  
  43.  
  44.  
  45. return cell
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement