Adding a Todo task
So far, the app works very well, presenting all the Todo
tasks, but we need to allow the user to create their own Todo
task.
The add a Todo ViewController
As the specifications require that a Todo
task be editable, it does make sense to use the same ViewController, either to create a new Todo
task, or to edit an already existing Todo
task. First of all, we need to implement the addTodoButtonPressed()
action:
func addTodoButtonPressed(sender: UIButton!){ let addTodoVC = EditTodoViewController(todosDatastore: todosDatastore, todoToEdit: nil) addTodoVC.title = "New Todo" navigationController!.pushViewController(addTodoVC, animated: true) }
Let's implement editButtonPressed()
as well:
func editButtonPressed(todo: Todo){ let editTodoVC = EditTodoViewController(todosDatastore: todosDatastore, todoToEdit: todo) editTodoVC.title = "Edit Todo" navigationController!.pushViewController(editTodoVC, animated: true) }
As you can see, the differences between...