Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(NSMutableArray *) getWatchHomeView
- {
- NSMutableArray *resultTracks = [[NSMutableArray alloc] init];
- self.ongoingMapArray = [NSArray arrayWithArray:[[self fetchResultsForCompletedExpeditions:NO] fetchedObjects]];
- NSLog(@"ongoingMapArray-- %lu",(unsigned long)[self.ongoingMapArray count]);
- self.completedMapArray = [NSArray arrayWithArray:[[self fetchResultsForCompletedExpeditions:YES] fetchedObjects]];
- NSLog(@"completedMapArray-- %lu",(unsigned long)[self.completedMapArray count]);
- for (int i=0; i < self.completedMapArray.count; i++)
- {
- WatchTable *watchTableRow = [[WatchTable alloc] init];
- Map *mapObject = [self.completedMapArray objectAtIndex:i];
- watchTableRow.trackName = [[NSString stringWithFormat:@"%@", [mapObject name]] uppercaseString];
- NSArray *arrPolylines = [NSArray arrayWithArray:[[self fetchPloylineForMaps:[mapObject name]] fetchedObjects]];
- if ([arrPolylines count] > 0) {
- double totalDis = [self getTotalDistanceFromPolylines:arrPolylines];
- watchTableRow.trackedDistance = [NSString stringWithFormat:@"%.2f km", totalDis];
- Polyline *firstPolyline = [arrPolylines lastObject];
- NSMutableArray *arrTimeData = (NSMutableArray*)firstPolyline.time;
- if ([arrTimeData count] > 0) {
- watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:[arrTimeData lastObject]]];
- }else{
- watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:firstPolyline.creationDate]];
- }
- }else{
- watchTableRow.trackedTime = [NSString stringWithFormat:@"%@ ago", [self getPausedTimeWithCreationDate:mapObject.creationDate]];
- watchTableRow.trackedDistance = [NSString stringWithFormat:@"0.00 Km"];
- }
- NSLog(@"watchTableRow = %@",watchTableRow);
- [resultTracks addObject:watchTableRow];
- }
- [[NSUserDefaults standardUserDefaults] setObject:resultTracks forKey:@"WatchHomeViewTableList"];
- return resultTracks;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement