再会!我通过 UIActivityItems 使用“将事件保存到日历”功能。在该功能中,我创建新日历并将事件添加到此日历:
EKEventStore* eventStore = [[EKEventStore alloc] init];
// Get the calendar source
EKSource* localSource;
for (EKSource* source in eventStore.sources) {
if (source.sourceType == EKSourceTypeLocal)
{
localSource = source;
break;
}
}
if (!localSource)
return;
EKCalendar *newCalendar = [EKCalendar calendarForEntityType:EKEntityTypeEvent eventStore:eventStore];
calendar.source = localSource;
calendar.title = @"New Calendar";
NSError *errorCalendar;
[eventStore saveCalendar:newCalendar commit:YES error:&errorCalendar];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = @"Title";
event.startDate = startDate;
event.endDate = endDate;
[event setCalendar:newCalendar];
// and etc.
及其工作。但每次下一次它都会再次创建名为“新日历”的新日历。如何检查具有该名称的日历是否已存在?以及如何更改日历类型?生日等。