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 2 By Example now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.