我在创建 EKCalendar 时遇到问题,一切看起来都很好,但是当我去列出我的日历时,它没有显示出来。我还去我的日历应用程序中检查我的日历列表,但它不存在。有什么想法吗?
这是我创建日历的按钮代码:
- (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);
}
这是我列出日历的按钮代码,但我的新日历从未包含在内!
- (IBAction)two:(id)sender {
NSArray *calendars = [eventStore calendarsForEntityType:EKEntityTypeEvent];
for (EKCalendar* cal in calendars){
NSLog(@"%@",cal.title);
}
}
先感谢您!