我有一个可以在iOS 11之前运行的应用程序,该应用程序可以从日历中检索事件,但无法在iOS 12中读取事件,下面的代码可以正常工作
- (NSArray *)fetchEventsForSelectedWeek {
if (!self.isCalendarAccessGranted) {
return nil;
}
NSDate *startDate = [self datePreviousSelectedDay];
NSDate *endDate = [NSDate date];
NSArray *calendarArr = [self.eventStore
calendarsForEntityType:EKEntityTypeEvent];
NSPredicate *currentWeekPredicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArr];
NSArray *events = [self.eventStore eventsMatchingPredicate:currentWeekPredicate];
return events;
}
我调试了代码,下面是我的建议