- Hands-On Full:Stack Development with Swift
- Ankur Patel
- 71字
- 2025-02-20 17:34:07
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
}