I'm stuck with a fetching request on EKEvents.
Following Apple samples, I created two dates 20 yrs before now, and 20 yrs in the future.
NSDateComponents *twentyYearsAgoComponents = [[NSDateComponents alloc] init];
twentyYearsAgoComponents.year = -20;
NSDate *twentyYearsAgo = [[NSCalendar currentCalendar] dateByAddingComponents:twentyYearsAgoComponents
toDate:[NSDate date]
options:0];
// Create the end date components
NSDateComponents *twentyYearsFromNowComponents = [[NSDateComponents alloc] init];
twentyYearsFromNowComponents.year = 20;
NSDate *twentyYearsFromNow = [[NSCalendar currentCalendar] dateByAddingComponents:twentyYearsFromNowComponents
toDate:[NSDate date]
options:0];
NSPredicate *predicate = [self.eventStoreGD predicateForEventsWithStartDate:twentyYearsAgo endDate:twentyYearsFromNow calendars:@[self.calendarForEventGD]]; // nil = all calendars
NSLog(@"predicate : %@",predicate);
In the console, I printed this :
2015-04-10 14:52:52.825 ohmygoods[1658:270016] [dateFormatter stringFromDate:twentyYearsFromNow] : 2035-04-10
2015-04-10 14:53:06.120 ohmygoods[1658:270016] predicate : EKEventPredicate start:10/04/1995 14:51; end:10/04/1999 14:51; cals:(
"x-apple-eventkit:///Calendar/p11"
)
You see
end:10/04/1999 14:51
Instead of 10/04/2035 ???