判断是否可以访问日历
EKEventStore *store = [[EKEventStore alloc] init];
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted == YES) {
NSLog(@"同意");
}else{
NSLog(@"不同意");
}
}];
获取日历事件
// 获取适当的日期(Get the appropriate calendar)
NSCalendar *calendar = [NSCalendar currentCalendar];
// 创建起始日期组件(Create the start date components)
NSDateComponents *oneDayAgoComponents = [[NSDateComponents alloc] init];
oneDayAgoComponents.day = -1;
NSDate *oneDayAgo = [calendar dateByAddingComponents:oneDayAgoComponents
toDate:[NSDate date]
options:0];
// 创建结束日期组件(Create t