Guest User

Untitled

a guest
Nov 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  2. let sportCell = tableView.dequeueReusableCell(withIdentifier: "sportCell", for: indexPath) as! TableViewCell
  3.  
  4.  
  5. if segmentControl.selectedSegmentIndex == 0 {
  6.  
  7.  
  8. let insertRow = (soccerString.count - 1) - indexPath.row
  9. let soccer = soccerString[insertRow]
  10.  
  11. sportCell.matchLabel.text = soccer.matchS
  12. soccerString[insertRow].imagePrS.getDataInBackground {(data, error) in
  13. sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
  14. }
  15. }
  16. else if segmentControl.selectedSegmentIndex == 1 {
  17.  
  18. let newIndex = (basketString.count - 1) - indexPath.row
  19. let basket = basketString[newIndex]
  20. sportCell.matchLabel.text = basket.matchB
  21. basketString[newIndex].imagePrB.getDataInBackground {(data, error) in
  22. sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
  23.  
  24. }
  25.  
  26. } else if segmentControl.selectedSegmentIndex == 2 {
  27.  
  28. let newInt = (tennisString.count - 1) - indexPath.row
  29. sportCell.matchLabel.text = tennisString[newInt].matchT
  30.  
  31. tennisString[newInt].imagePrT.getDataInBackground {(data, error) in
  32. sportCell.imageMatch.image = error == nil ? UIImage(data: data!) : nil
  33.  
  34. }
  35.  
  36. }
  37.  
  38.  
  39.  
  40. sportCell.selectionStyle = UITableViewCellSelectionStyle.none
  41.  
  42. let date = Date()
  43. let calendar = Calendar.current
  44.  
  45.  
  46.  
  47. let dateFormatter = DateFormatter()
  48.  
  49. dateFormatter.dateStyle = .short
  50. dateFormatter.timeStyle = .short
  51. dateFormatter.locale = Locale(identifier: "ru_UA")
  52. dateFormatter.doesRelativeDateFormatting = true
  53.  
  54.  
  55. if let today = calendar.date(byAdding: .day, value: 0, to: date) {
  56.  
  57. sportCell.dataSave.text = dateFormatter.string(from: today)
  58.  
  59. } else if let yesterday = calendar.date(byAdding: .day, value: -1, to: date) {
  60.  
  61. sportCell.dataSave.text = dateFormatter.string(from:yesterday)
  62. } else {
  63. sportCell.dataSave.text = dateFormatter.string(from: date)
  64.  
  65. }
  66.  
  67. sportCell.setNeedsLayout()
  68. sportCell.layoutIfNeeded()
  69.  
  70. return sportCell
  71. }
Add Comment
Please, Sign In to add comment