Adding a timestamp property

A ToDoItem can also have a due date represented by a timestamp. Add the following test to make sure we can initialize an instance of ToDoItem with timestamp:

func test_Init_SetsTimestamp() { 
  let item = ToDoItem(title: "",                       timestamp: 0.0)   XCTAssertEqual(item.timestamp, 0.0,                  "should set timestamp") 
} 

Again, this test does not compile because there is an extra argument in the initializer. From the implementation of the other properties, we know that we have to add a timestamp property in ToDoItem and set it in the initializer:

struct ToDoItem { 
  let title: String 
  let itemDescription: String? 
  let timestamp: Double? 
  
 
  init(title: String, 
       itemDescription: String? = nil, 
       timestamp: Double? = nil) { self.title = title ...

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.