我正在使用以下代码来处理过去的事件。请告诉我过去事件的解决方案
NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
NSPredicate *fetchCalendarEvents = [store predicateForEventsWithStartDate:[NSDate distantPast] endDate:endDate calendars:nil];
NSArray *eventList = [store eventsMatchingPredicate:fetchCalendarEvents];
NSLog(@"allevent:%@",eventList);
答案 0 :(得分:0)
请按照以下代码
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:[[NSDate distantFuture] timeIntervalSinceReferenceDate]];
NSArray *calendarArray = [NSArray arrayWithObject:cal];
NSPredicate *fetchCalendarEvents = [eventStore predicateForEventsWithStartDate:[NSDate date] endDate:endDate calendars:calendarArray];
NSArray *eventList = [eventStore eventsMatchingPredicate:fetchCalendarEvents];
for(int i=0; i < eventList.count; i++)
{
NSLog(@"Event Title:%@", [[eventList objectAtIndex:i] title]);
}