Building the Todos screen
Let's move on to populate the ViewController we have just created with the proper entities.
Adding the entities
The first thing we need to do is to create the entities, which is really straightforward. Basically, we just need to map the requested fields in a struct
:
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 }
Implementing the datastore
Next, we create the datastore to handle all the operations of the entities.
For now, we only return two lists of entities:
class TodosDatastore { private var savedLists = Array<List>() private var savedTodos = Array<Todo>() init(){ savedLists = [ List(description: "Personal"), List...