Вы можете попробовать этот подход:
1) Получить все заявки с ДА, отсортированные по дате
2) Пройдите по этому массиву и заполните массив словарями со значением дня и числом йес
3) Затем выполните ame с помощью noe, добавив число no к этому массиву словарей.
NSFetchRequest *request = [[NSFetchRequest alloc]init];
request.entity = [NSEntityDescription entityForName:@"Day" inManagedObjectContext:context];
request.predicate = [NSPredicate predicateWithFormat:@"yesorno = %@",YES];
NSError *error = nil;
request.sortDescriptors =[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]];
//Here you get all the enteties with YES,sorted by date
NSArray *days = [context executeFetchRequest:request error:&error];
NSMutableArray *arrayOfDates = [NSMutableArray array];
int firstDay = [[[NSCalendar currentCalendar]components:NSDayCalendarUnit fromDate:[[days objectAtIndex:0]date]]day];
//Add the first day dictionary
[arrayOfDates addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[[days objectAtIndex:0]date],@"Day", nil];
int numberOfYes = 0;
int dayNumber = 0;
for(NSManagedObject *day in days)
{
if( [[[NSCalendar currentCalendar]components:NSDayCalendarUnit fromDate:[day date]]day]>firstDay)
{
//save number of yeses for the previous day,because we are done with it
[[arrayOfDates objectAtIndex:dayNumber]setValue:[NSNumber numberWithInt:numberOfYes] forKey:@"NumberOfYes"];
numberOfYes = 1;
dayNumber++;
firstDay = [[[NSCalendar currentCalendar]components:NSDayCalendarUnit fromDate:[day date]]day];//date with new day
[arrayOfDates addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[day date],@"Day", nil];//Add this day dictionary to array
}else
{
numberOfYes++;
}
}
//And somrthing similar to No