Hello everyone,
i am struggling with chapter 19 - adding the Consulting to the project. i followed steps in the Book iOS Apprentice but when i run the code, it threw this error back
`Error decoding item array: The data couldn’t be read because it is missing.`
, and on the Simulator , there is no icon appeared. Could anyone give me a hint ?
thank you in Advance !
AllListsViewController.swift#######
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { //let cell = makeCell(for: tableView) let cell: UITableViewCell!
if let c = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) {
cell = c
}else {
cell = UITableViewCell(style: .subtitle, reuseIdentifier: cellIdentifier)
}
// Update cell information
let checklist = dataModel.lists[indexPath.row]
cell.textLabel!.text = checklist.name
cell.accessoryType = .detailDisclosureButton
// Access subtitle of label
cell.detailTextLabel!.text = "\(checklist.countUncheckedItems()) Remaining"
let count = checklist.countUncheckedItems()
if checklist.items.count == 0 {
cell.detailTextLabel!.text = "(No items)"
}else {
cell.detailTextLabel!.text = count == 0 ? "All done!" : "\(count) Remaining"
}
cell.imageView!.image = UIImage(named: checklist.iconName)
return cell
}`
################# Checklist.swift #######################
`import UIKit
class Checklist: NSObject, Codable {
var name = “”
var items = ChecklistItem
var iconName = “”
init(name: String) {
self.name = name
super.init()
}
// Counting the unchecked items
func countUncheckedItems() -> Int {
return items.reduce(0) {cnt, item in cnt + (item.checked ? 0 : 1)}
}
}`