Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var newItemText = UITextField()
- let alert = UIAlertController(title: "Add a new Todoey Item", message: "", preferredStyle: .alert)
- let action = UIAlertAction(title: "Add Item", style: .default) { (action) in
- // what's going to happen when the add button is pressed
- let newTodoItem = TodoListItem(context: self.context)
- newTodoItem.title = newItemText.text!
- newTodoItem.isChecked = false
- self.itemArray.append(newTodoItem)
- self.saveItems()
- }
- alert.addTextField { (alertTextField) in
- alertTextField.placeholder = "Create new item"
- newItemText = alertTextField
- }
- alert.addAction(action)
- present(alert, animated: true, completion: nil)
Add Comment
Please, Sign In to add comment