I currently have a FRC for my sections which are loaded from a transient property.
I'd like to let the user limit what he sees to for example one specific month.
I read an answer somewhere that said to add a method because the predicate calls it so I tried adding a method to the managed object class .m file like so:
@property (nonatomic) NSInteger monthOfDate;
@synthesize monthOfDate;
-(NSInteger) monthOfDate
{
NSDate *date = [self theDate];
NSDateComponents *components = [[NSCalendar currentCalendar]components: NSCalendarUnitMonth fromDate:date];
NSInteger month = [components month];
return month;
}
but when used in a predicate like so:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"monthOfDate == %d", 6];
I get the error: Keypath monthOfDate not found in entity.
Is this anyhow possible or should I make the month an additional attribute when the date is saved? I read some answers advising to compare a start and end date. But the user will be able to select a wide range of custom dates (a year, a month, weeks, specific day to day) so that seems like a long way to go about this..