Добрый день! Я использую функцию «Сохранить событие в календаре» через 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.
И это работает. Но каждый следующий раз он снова создает новый календарь с именем «Новый календарь». Как я могу проверить, существует ли уже календарь с таким названием? И как я могу изменить тип календаря? В день рождения или др.