Как сделать дату (сегодня, вчера, дата) в TableViewCell?

swift

#1

Не получается сделать дату, чтоб выводило для каждой ячейки . У меня три массива . Например я событие это если загрузилось сегодня так и показывало, что сегодня, а потом меняло на вчера и потом на обычную дату, когда оно было загружено.Почему то при загрузки нового события , старое событие указывает время нового загруженного.Подскажите с чем это связано.И как сделать метод.
Вот мой код.

        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            let sportCell = tableView.dequeueReusableCell(withIdentifier: "sportCell", for: indexPath) as! TableViewCell
            
           
                if segmentControl.selectedSegmentIndex == 0  {
                  
            
                 let insertRow = (soccerString.count - 1) - indexPath.row
                 let soccer = soccerString[insertRow]
                    
                sportCell.matchLabel.text = soccer.matchS
            
                soccerString[insertRow].imagePrS.getDataInBackground {(data, error) in
                sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
                    }
                }
                else if segmentControl.selectedSegmentIndex == 1 {
        
                let newIndex = (basketString.count - 1) - indexPath.row
                let basket = basketString[newIndex]
                sportCell.matchLabel.text = basket.matchB
                basketString[newIndex].imagePrB.getDataInBackground {(data, error) in
                    sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
                    
                }
                
                }  else if segmentControl.selectedSegmentIndex == 2 {
                 
                 let newInt = (tennisString.count - 1) - indexPath.row
                sportCell.matchLabel.text = tennisString[newInt].matchT
               
                tennisString[newInt].imagePrT.getDataInBackground {(data, error) in
                        sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
                    
                }
            
         }
            
            
            
            sportCell.selectionStyle = UITableViewCellSelectionStyle.none
           
            let date = Date()
            let dateFormatter = DateFormatter()
            let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: date)
             let today = Calendar.current.date(byAdding: .day, value: 0, to: date)
            dateFormatter.dateStyle = .short
            dateFormatter.timeStyle = .short
            dateFormatter.locale = Locale(identifier: "ru_UA")
            dateFormatter.doesRelativeDateFormatting = true
           
            if (date == today) {
                
                sportCell.dataSave.text = dateFormatter.string(from: today!)
            } else if (date==yesterday!) {
                sportCell.dataSave.text = dateFormatter.string(from: yesterday!)
                
            } else {
                sportCell.dataSave.text = dateFormatter.string(from: date)
            }
           
            
            sportCell.setNeedsLayout()
            sportCell.layoutIfNeeded()
          
            return sportCell
 }

Пожалуйста поправьте меня и чтоб я не правильно отобразил.Буду благодарен очень!