Hi guys!!I have resolved this bronze challenge adding four lines to function which creates the cells accessing to he background property.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//let cell = UITableViewCell(style: .value1, reuseIdentifier: "UITableViewCell")
if (indexPath.row < itemStore.allItems.count ){
let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath) as! ItemCell
let item = itemStore.allItems[indexPath.row]
// cell.textLabel?.text = item.name
// cell.detailTextLabel?.text = "\(item.valueInDollars)"
cell.nameLabel.text = item.name
cell.serialNumber.text = item.serialNumber
cell.valueLabel.text = "\(item.valueInDollars)"
if item.valueInDollars < 50 {
cell.backgroundColor = UIColor.green
}else if item.valueInDollars >= 50 {
cell.backgroundColor = UIColor.red
}
return cell
} else {
let cell = UITableViewCell(style: .value1, reuseIdentifier: "UITableviewCell")
cell.textLabel?.text = "No more items!!"
return cell
}
}
I hope this will help if you need it