I've been going around this question Here
And trying to implement my own solution. Somehow, I don't get any sections. Only rows.
3 rows in this case... But no Sections. There should be 2 sections at least. 2 Months. I know this because I inspected the model and they are there.
My Core Data Model has an entity Year, containing many months (Entity Month). And Month has also many days (Entity Day)
The attributes that represent each one individualy are, year_, month_ and day_, for the entities Year, Month and Day, respectively.
What I'm trying to do is a fetch request to all days, in a given Month, in a Given Year in a way that I can have my sections representing a Month and Rows representing Days.
Can someone help me out?
edit: updated code
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Day" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"day_" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
[fetchRequest setFetchBatchSize:20];
NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:managedObjectContext
sectionNameKeyPath:@"month.month_"
cacheName:@"Root"];
My model is looking like this,
Any help is greatly appreciated.
Thank you!
Nuno