Sto sviluppando l'app di calendario. Sto cercando di salvare EKEvent usando EKCalender assegnato. Ma quando provo a eseguire il codice seguente mi dà errore. Si prega di aiutareErrore nell'acquisizione di inviti di calendario condivisi per i tipi di entità 3, Xcode 6.1.1. EKCalender, EKSource, EKEventstore e Objective C
-(BOOL)createEventWithTitle:(NSString *)paramTitle startDate:(NSDate *)paramStartDate endDate:(NSDate *)paramEndDate inCalendar:(EKCalendar *)paramCalendar inEventStore:(EKEventStore *)paramStore notes:(NSString *)paramNotes
{
BOOL result = NO;
//paramCalendar = [self.eventStoreiReportShifts defaultCalendarForNewEvents];
if (self.eventsAccessGranted) {
NSArray *caledars = [self.eventStore calendarsForEntityType:EKEntityTypeEvent];
self.selectedCalendarEventKitIdentifier = [[NSUserDefaults standardUserDefaults] objectForKey:@"eventkit_cal_identifiers_string"];
for(EKCalendar *aCal in caledars){
if([aCal.calendarIdentifier isEqualToString:self.selectedCalendarEventKitIdentifier]){
paramCalendar = [self.eventStore calendarWithIdentifier:[[NSUserDefaults standardUserDefaults] objectForKey:@"eventkit_cal_identifiers_string"]];
}
}
for (EKSource *source in self.eventStore.sources) {
if (source.sourceType == EKSourceTypeCalDAV) {
paramCalendar.source = source;
break;
} else if(source.sourceType == EKSourceTypeLocal){
paramCalendar.source = source;
break;
}
}
}else{
return NO;
}
/* If a calendar does not allow modification of its contents
then we can not insert an event into it */
if (paramCalendar.allowsContentModifications == NO) {
NSLog (@ "\n\n The selected calendar does not allow modifications.");
return NO;
}
/* Create an event */
EKEvent * event = [EKEvent eventWithEventStore:paramStore];
event.calendar = paramCalendar;
/* Set the properties of the event such as its title,
start date/time, end date/time, etc. */
event.title = paramTitle;
event.notes = paramNotes;
event.startDate = paramStartDate;
event.endDate = paramEndDate;
/* Finally, save the event into the calendar */
NSError * saveError = nil;
result = [paramStore saveEvent:event
span:EKSpanThisEvent
error:&saveError];
if (result == NO) {
NSLog (@ "\n\n An error occurred = %@", saveError);
}
return result;
}
sopra codice fornisce seguente errore
CalendarCalculations[1668:45103]
Error getting shared calendar invitations for entity types 3 from
daemon: Error Domain=EKCADErrorDomain Code=1013
"The operation couldn’t be completed. (EKCADErrorDomain error 1013.)"
come posso liberarmi di esso per favore?
Un buon suggerimento che ciò potrebbe accadere solo quando non sono presenti calendari condivisi! – ctietze
Ogni tanto mi capita di trovarlo su un dispositivo che ha un sacco di calendari condivisi, ma che usa Google invece di iCloud. non sembra influire sulla funzionalità, ma effettua il debug di una PITA poiché inonda il log di merda. –
Funziona alla grande.Grazie mille :) –