I'm having an issue where I create my EKCalendar and everything looks good but then when I go to list my calendars, it doesn't show up. I also go to check my calendar list in my calendar app but it is non existant. Any thoughts?
Here is my button code to create my calendar:
- (IBAction)one:(id)sender {
NSString* calendarName = @"My Cal";
EKCalendar* calendar;
// Get the calendar source
EKSource* localSource;
for (EKSource* source in eventStore.sources) {
if (source.sourceType == EKSourceTypeLocal)
{
localSource = source;
break;
}
}
if (!localSource)
return;
calendar = [EKCalendar calendarWithEventStore:eventStore];
calendar.source = localSource;
calendar.title = calendarName;
NSError* error;
bool success= [eventStore saveCalendar:calendar commit:YES error:&error];
if (error != nil)
{
NSLog(error.description);
// TODO: error handling here
}
NSLog(@"cal id = %@", calendar.calendarIdentifier);
}
And here is my button code to list the calendar, but my new calendar is never included!
- (IBAction)two:(id)sender {
NSArray *calendars = [eventStore calendarsForEntityType:EKEntityTypeEvent];
for (EKCalendar* cal in calendars){
NSLog(@"%@",cal.title);
}
}
Thank you in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…