Hands-On Full:Stack Development with Swift
上QQ阅读APP看书,第一时间看更新

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
}