O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating a Todo item

Finally, we want to be able to update an item in our Todo list to complete it or take some notes:

/// Update a specific todo item drop.post("updateTodo") { request in     guard let id = request.headers["id"]?.int,         let name = request.headers["name"],         let description = request.headers["description"],         let notes = request.headers["notes"],         let completed = request.headers["completed"],         let synced = request.headers["synced"]         else {             return try JSON(node: ["message":                                    "Please include mandatory parameters"])         }         let todoItem = Todo(todoId: id,                             name: name,                             description: description,                             notes: notes,                             completed: completed.toBool()!,                             synced: synced.toBool()!)         let todos = TodoStore.sharedInstance  let message = todos.update(item: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required