获取当天的日历事件:
NSTimeInterval secondsPerDay = 24 * 60 * 60;
NSDate * startDate = [NSDate date];
NSDate * endDate = [[NSDate alloc] initWithTimeIntervalSinceNow:secondsPerDay];
NSArray * calendarArray = [NSArray arrayWithObject:self.defaultCalendar];
NSPredicate * predicate = [self.eventStore predicateForEventsWithStartDate:startDate
endDate:endDate
calendars:calendarArray];
NSMutableArray *events = [NSMutableArray arrayWithArray:[self.eventStore eventsMatchingPredicate:predicate]];
获取前一天的日历事件:
NSDate * startDate = [NSDate date];
NSDate * endDate = [[NSDate alloc]initWithTimeInterval:(-secondsPerDay)sinceDate:startDate];
NSArray * calendarArray = [NSArray arrayWithObject:self.defaultCalendar];
NSPredicate * predicate = [self.eventStore predicateForEventsWithStartDate:endDate
endDate:startDate
calendars:calendarArray];
NSMutableArray *events = [NSMutableArray arrayWithArray:[self.eventStore eventsMatchingPredicate:predicate]];