我想根据某些键或日期获取 iPhone 的日历事件。我的真正目的是调用一个函数,该函数获取到目前为止添加的事件列表,但是将来当我再次调用此函数时,它必须只给我新添加的事件而不是重复的事件。直到现在我收到了这样的事件
EKEventStore *store = [[EKEventStore alloc] init];
if ([store respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
/* iOS Settings > Privacy > Calendars > MY APP > ENABLE | DISABLE */
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
if ( granted )
{
// Create the predicate from the event store's instance method
NSPredicate *predicate = [store predicateForEventsWithStartDate:startDate
endDate:endDate calendars:nil];
// Fetch all events that match the predicate
NSArray *events = [store eventsMatchingPredicate:predicate];
NSLog(@"The content of array is%@",events);
}
}];
}
但这给了我该日期的所有事件,而不仅仅是新事件。