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 O’Reilly online learning.

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