Adding a location property

The last property that we would like to be able to set in the initializer of ToDoItem is its location. The location has a name and can optionally have a coordinate. We will use a struct to encapsulate this data into its own type. Add the following code to ToDoItemTests:

func test_Init_WhenGivenLocation_SetsLocation() { 
  let location = Location(name: "Foo") 
} 

The test is not finished, but it already fails because Location is an unresolved identifier. There is no class, struct, or enum named Location yet. Open the Project Navigator, add a Swift file with the name Location.swift to the ToDo target. From our experience with the ToDoItem struct, we already know what is needed to make the test green. Add the following ...

Get Test-Driven iOS Development with Swift 4 - Third Edition 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.