I suppose sorting by date works correctly.
If you want your function to collect all Objects with a specific date, it could look like this (assuming your object employee is a NSDictionary or NSMutableDictionary);
-(NSArray*)getObjectsWithDate: (NSDate*) date fromArray:(NSArray*) array
{
NSMutableArray *retArray = [[NSMutableArray alloc]init];
BOOL b_enteredCorrectDateArea = NO;
for (NSDictionary *dict in array) {
NSDate *dateFromDict = [dict objectForKey:@"date"];
//Updated section
unsigned int flags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:flags fromDate:dateFromDict];
NSDate* dateFromDictWithoutTimeComponent = [calendar dateFromComponents:components];
components = [calendar components:flags fromDate:date];
NSDate *dateFromArgumentsWithoutTimeComponent = [calendar dateFromComponents:components];
//end of update
if ([dateFromArgumentsWithoutTimeComponent isEqualToDate:dateFromDictWithoutTimeComponent]) {
[retArray addObject:dict];
if (!b_enteredCorrectDateArea) {
b_enteredCorrectDateArea = YES;
}
}
else if(b_enteredCorrectDateArea) //performance Optimization
{
break;
}
}
return retArray;
}
If you then want to display your filtered Data, just use the returned Array as datasource for your UITableView and reload the tableview after assigning the array as datasource.
Of course this is not tested, since i have not test-data.
But it should work like this.
If this works for you, please do also upvote this post, since it showed me, how to just use the date without time. :)