Guest User

Untitled

a guest
Nov 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. func getData() {
  2. let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
  3. do {
  4. tasks = try context.fetch(Task.fetchRequest())
  5. }
  6. catch{
  7. print("Fetching Failed")
  8. }
  9. }
  10.  
  11. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  12. let cell = tableView.dequeueReusableCell(withIdentifier: "customCell") as! CustomTableViewCell
  13.  
  14. let task = tasks[indexPath.row]
  15.  
  16.  
  17. let dateRangeStart = Date()
  18. let dateRangeEnd = task.Datum
  19. let components = Calendar.current.dateComponents([.year, .weekOfYear, .month, .day], from: dateRangeStart, to: dateRangeEnd!)
  20.  
  21.  
  22. cell.name.text = task.name
  23. cell.dayLeft.text = "(components.month ?? 0)M (components.weekOfYear ?? 0)W (components.day ?? 0)D"
  24.  
  25. return cell
  26. }
  27.  
  28. meetingsData.sort({ $0.meetingDate.compare($1.meetingDate) == .OrderedAscending })
  29.  
  30. meetingData = meetingData.sorted{ $0.meetingDate < $1.meetingDate }
Add Comment
Please, Sign In to add comment