In my tableviewCell class, i set the progressview as (ignore the class name, using Food as simplicity) :
func setupCell(list: Food) {
documentTitle.text = list.nickname
if let spoiltFood = list.spoilt, let totalFood = list.totalFood {
DispatchQueue.main.async {
self.progressView.progress = Float(spoiltFood/totalFood)
}
}
}
Then in my UITableView, i call it as :
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! FoodTableViewCell
if let foodList = self.foodList {
cell.setupCell(list: foodList[indexPath.row])
}
return cell
}
However, the progress view updates itself and right after 0.5 seconds, i see it being reset. Does anyone have any ideas or suggestion on how we are able to solve the issue?