How it works...

The task API will accept new tasks as POST requests containing JSON representations of the tasks and will return all the existing tasks via GET requests.

First, let's define a task--in the App group of your XCode project, create a new file called Task.swift in the Models group.

After creating this file, ensure that it is a member of the App target and not any others. The Target Membership panel for our new file should look like this:

Now, let's define our task as having two properties: a description and a category, plus an identifier:

class Task {      let id: String      var description: String    var category: String     init(id: String, ...

Get Swift 4 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.