Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 calendar = Calendar.current
- let dateFormatter = DateFormatter()
- dateFormatter.dateStyle = .short
- dateFormatter.timeStyle = .short
- dateFormatter.locale = Locale(identifier: "ru_UA")
- dateFormatter.doesRelativeDateFormatting = true
- if let today = calendar.date(byAdding: .day, value: 0, to: date) {
- sportCell.dataSave.text = dateFormatter.string(from: today)
- } else if let yesterday = calendar.date(byAdding: .day, value: -1, to: date) {
- sportCell.dataSave.text = dateFormatter.string(from:yesterday)
- } else {
- sportCell.dataSave.text = dateFormatter.string(from: date)
- }
- sportCell.setNeedsLayout()
- sportCell.layoutIfNeeded()
- return sportCell
- }
Add Comment
Please, Sign In to add comment