Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. -(NSMutableArray *) getWatchHomeView
  2. {
  3.  
  4. NSMutableArray *resultTracks = [[NSMutableArray alloc] init];
  5. self.ongoingMapArray = [NSArray arrayWithArray:[[self fetchResultsForCompletedExpeditions:NO] fetchedObjects]];
  6. NSLog(@"ongoingMapArray-- %lu",(unsigned long)[self.ongoingMapArray count]);
  7. self.completedMapArray = [NSArray arrayWithArray:[[self fetchResultsForCompletedExpeditions:YES] fetchedObjects]];
  8. NSLog(@"completedMapArray-- %lu",(unsigned long)[self.completedMapArray count]);
  9.  
  10. for (int i=0; i < self.completedMapArray.count; i++)
  11. {
  12. WatchTable *watchTableRow = [[WatchTable alloc] init];
  13. Map *mapObject = [self.completedMapArray objectAtIndex:i];
  14.  
  15. watchTableRow.trackName = [[NSString stringWithFormat:@"%@", [mapObject name]] uppercaseString];
  16. NSArray *arrPolylines = [NSArray arrayWithArray:[[self fetchPloylineForMaps:[mapObject name]] fetchedObjects]];
  17.  
  18. if ([arrPolylines count] > 0) {
  19. double totalDis = [self getTotalDistanceFromPolylines:arrPolylines];
  20. watchTableRow.trackedDistance = [NSString stringWithFormat:@"%.2f km", totalDis];
  21.  
  22.  
  23. Polyline *firstPolyline = [arrPolylines lastObject];
  24. NSMutableArray *arrTimeData = (NSMutableArray*)firstPolyline.time;
  25. if ([arrTimeData count] > 0) {
  26. watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:[arrTimeData lastObject]]];
  27. }else{
  28. watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:firstPolyline.creationDate]];
  29. }
  30. }else{
  31. watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:mapObject.creationDate]];
  32. watchTableRow.trackedDistance = [NSString stringWithFormat:@"0.00 Km"];
  33. }
  34. NSLog(@"watchTableRow = %@",watchTableRow);
  35. [resultTracks addObject:watchTableRow];
  36.  
  37. }
  38.  
  39. [[NSUserDefaults standardUserDefaults] setObject:resultTracks forKey:@"WatchHomeViewTableList"];
  40.  
  41. return resultTracks;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement