NSMutableArray *tempDateArray = [[NSMutableArray alloc]init];
for (int i = 0; i < [arrProjectList count]; i++) {
NSString *strThisDate = [[arrProjectList objectAtIndex:i]valueForKey:@"Last_Date"];
NSLog(@"\n\n Date here %@",strThisDate);
[strThisDate retain];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"EEE, dd-LLL-yyyy"];
NSDate *date = [dateFormatter dateFromString: strThisDate];
// date = [self convertStringToDate:strThisDate];
strThisDate = [date stringFromDateWithFormat:@"yyyy-MM-dd 00:00:00 +0000"];
[tempDateArray addObject:strThisDate];
}
[tempDateArray retain];
NSArray *arrDates = [[NSArray alloc]initWithArray:tempDateArray];
[arrDates retain];
[tempDateArray sortUsingSelector:@selector(compare:)];
NSMutableArray *temparrProjectList = [[NSMutableArray alloc]init];
for (int j = 0; j < [tempDateArray count]; j++) {
NSString *tempstrThisDate = [tempDateArray objectAtIndex:j];
for (int i = 0; i < [arrProjectList count]; i++) {
NSString *strThisDate = [[arrProjectList objectAtIndex:i]valueForKey:@"Last_Date"];
NSLog(@"\n\n Date here %@",strThisDate);
[strThisDate retain];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"EEE, dd-LLL-yyyy"];
NSDate *date = [dateFormatter dateFromString: strThisDate];
// date = [self convertStringToDate:strThisDate];
strThisDate = [date stringFromDateWithFormat:@"yyyy-MM-dd 00:00:00 +0000"];
if ([strThisDate isEqualToString:tempstrThisDate]) {
if (![temparrProjectList containsObject:[arrProjectList objectAtIndex:i]]) {
[temparrProjectList addObject:[arrProjectList objectAtIndex:i]];
}
}
}
}
[temparrProjectList retain];
arrProjectList = temparrProjectList;
No comments:
Post a Comment