I need to display Int in TableViewCell label to get sum the values. Here is my code:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "eventCell", for: indexPath) as! BudgetTableViewCell
let budgetEvent: BudgetModel
budgetEvent = budgetList[indexPath.row]
cell.nameEventLabel.text = budgetEvent.eventName
cell.spentBudgetLabel.text = String(budgetEvent.spentBudget!)
let totalSpent = budgetList.map{ $0.spentBudget! }.reduce(0, +)
print("sum \(totalSpent)")
return cell
}
When I run my app I have error message:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value"
and the value is nil.