Building the Todos screen

Let's move on to populating the View Controller we just created with the proper entities.

Adding entities

The first thing we need to do is create entities, which is really straightforward. Basically, we just need to map the requested fields in struct:

import Foundation

struct Todo: Equatable {
    let description: String
    let list: List
    let dueDate: NSDate
    let done: Bool
    let doneDate: NSDate?
}

func ==(todo1: Todo, todo2: Todo) -> Bool {
    return todo1.description == todo2.description
    && todo1.dueDate == todo2.dueDate
}

struct List {
    let description: String
}

Foundation is the core module in Swift, and it contains fundamental objects, for example, NSDate, which is required to implement every kind of app.

Implementing datastore

Get Swift: Developing iOS Applications 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.