1
美好的一天! 我使用功能「通過UIActivityItems將事件保存到日曆」。在該功能中,我創建了新日曆並將事件添加到此日曆中:檢查EKCalendar
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.
而且它的工作。但是,下次每次都會再次創建名稱爲「新日曆」的新日曆。我如何檢查具有該名稱的日曆是否已經存在?我怎樣才能改變日曆的類型?在生日或其他時間