I have an UITableViewController
that shows a list using NSFetchedResultsController
.
This is a list of myObject and has a attribute date
.
I have created a method - (NSFetchedResultsController *)fetchedResultsController
to get all Entries sorted by date.
The result is this:
After this I have added the - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
so that time + date would be shown in dateStyle:NSDateFormatterMediumStyle
.
As shown below, you can see that the dates are printed properly, but the 2 lines with MAR 12, 2014 and the other 2 with MAR 14, 2014 are not grouped together.
My guess is that I need to change the numberOfSectionsInTableView
method, as it is still looking at the dates + time, and not only to the dates, but I have no idea how.
My code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger count = [[self.fetchedResultsController sections] count];
return count;
}
One possibility is to add an attribute to my Object like 'sectionIdentifier' to store only dates in it and use that. I would like to know if anyone has another idea how to approach this. Is it possible to get these dates grouped together my adding code to - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
?