【发布时间】:2013-10-31 11:11:35
【问题描述】:
我最近发现,在 iOS7 中我没有从 EKEventStore 收到任何 EKCalendar 对象。在 iOS 6.x.x 中,相同的代码 sn-p 没有问题。当我尝试访问 defaultCalendarForNewEvents - 我确实收到了一个 EKCalendar 对象(如预期的那样)。
我确实请求访问实体类型 EKEntityTypeEvent。
sn-p:
__block NSMutableArray *calendarsArray = nil;
if ([self.eventsStore respondsToSelector:@selector(requestAccessToEntityType:completion:)]) {
[self.eventsStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted) {
EKAuthorizationStatus status = [EKEventStore authorizationStatusForEntityType:EKEntityTypeEvent];
if (status == EKAuthorizationStatusAuthorized) {
calendarsArray = [[NSMutableArray alloc] initWithArray:[self.eventsStore calendarsForEntityType:EKEntityMaskEvent]];
}
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"You haven't granted access to calendars. Expected things are not going to happen." delegate:nil cancelButtonTitle:@"I understand" otherButtonTitles:nil];
[alert show];
}
}];
} else {
calendarsArray = [NSMutableArray arrayWithArray:[self.eventsStore calendarsForEntityType:EKEntityTypeEvent]];
}
我确实收到了 0 个对象到 calendarsArray。我还尝试通过“运行”所有类型为 Local 或 CalDAV 的 EKSource 来获得它([source calendarsForEntityType:] - 得到相同的空(包含 0 个对象)集)。
顺便说一句 - 已授予访问日历的权限。
有什么建议吗?
【问题讨论】:
-
这发生在 iPhone 4 和 iPhone 5(都运行 iOS 7.0.3)上。此外,在两台设备上,还通过 CalDAV 连接了两个日历。
-
另外,运行其他测试(编写附加应用程序等)我注意到在本地存储中也无法创建日历。
标签: objective-c ios7 ekeventkit