I am making countdown app with multiple records, so I am using UITableView to show that records and countdown dates. What I do is just take one timer and reload cells on every second. Is this a best approach to reload visible cells on every second or is there another better approach there?
updateCellContentsTimer = Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(ViewController.updateCells),
userInfo: nil, repeats: true)
// MARK: Custom Functions
func updateCells() {
let indexPathsArray = tableView.indexPathsForVisibleRows
for indexPath in indexPathsArray! {
let cell = tableView.cellForRow(at: indexPath) as! CountdownTableViewCell
cell.timeLeftLabel.text = progress + "hours:minutes:seconds"
}
}