Exercise answer

The following is the answer to generating fake items. Copy this code if you were not able to create your own version of generating fake items as we will need this later in our app:

static func fake(_ count: Int) -> [Item] {  var items = [Item]()  for i in 0...count {    let item = Item(name: "Item \(i)", isChecked: i % 2 == 0)    items.append(item)  }  return items}

Get Hands-On Full-Stack Development with Swift 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.