Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. let defaults = UserDefaults.standard
  2.  
  3. var needIndicatorArray: [String] = ["SNAP", "EBT", "FVRX"]
  4.  
  5. @IBAction func addNeedIndicator(_ sender: UIBarButtonItem) {
  6.  
  7. var textField = UITextField()
  8.  
  9. let alert = UIAlertController(title: "Add Need Indicator", message: "", preferredStyle: .alert)
  10.  
  11. let action = UIAlertAction(title: "Add Item", style: .default) { (action) in
  12. //This should append the global array once the user hits the add item on the UIAlert
  13. self.needIndicatorArray.append(textField.text!)
  14. }
  15.  
  16. alert.addTextField { (alertTextField) in
  17. alertTextField.placeholder = "Create new item"
  18. textField = alertTextField
  19. }
  20.  
  21. alert.addAction(action)
  22.  
  23. present(alert, animated: true, completion: nil)
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement