I have a problem on a tableview with section by date. I took the Apple example : DateSectionTitles
I don't care about year. I ust need month and day. So I adapt my code like that :
In my CoreData class :
- (NSString *)sectionIdentifier {
[self willAccessValueForKey:@"sectionIdentifier"];
NSString *tmp = [self primitiveSectionIdentifier];
[self didAccessValueForKey:@"sectionIdentifier"];
NSLog(@"!Temp");
if (!tmp) {
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[self timeStamp]];
tmp = [NSString stringWithFormat:@"%d", ([components month]*100) + [components day]];
[self setPrimitiveSectionIdentifier:tmp];
}
return tmp;}
And in my titleForHeaderInSection method in my main controller :
NSInteger month = numericSection / 100;
NSInteger day = numericSection - (month * 100);
NSString *titleString = [NSString stringWithFormat:@"%d %d",day, month];
return titleString;
But when I run my app I have this message :
CoreData: error: (NSFetchedResultsController) A section returned nil value for section name key path 'sectionIdentifier'. Objects will be placed in unnamed section
Do you know why ? Thanks for your help !