升级到 Mavericks 后,我的代码不再成功地将事件添加到日历中。我通过 Mavericks 开发人员发布说明没有找到与此问题相关的特定文档。
你知道如何让这段代码工作吗?
//Send new event to the calendar
NSString *calEventID;
EKEventStore *calStore = [[EKEventStore alloc]initWithAccessToEntityTypes:EKEntityTypeEvent];
EKEvent *calEvent = [EKEvent eventWithEventStore:calStore];
//Calendar Values
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
calEvent.title = @"TITLE";
calEvent.startDate = [NSDate date];
calEvent.endDate = [NSDate date];
calEvent.notes = @"Here are some notes";
[calEvent setCalendar:[calStore defaultCalendarForNewEvents]];
calEventID = [calEvent eventIdentifier];
NSError *error = nil;
[calStore saveEvent:calEvent span:EKSpanThisEvent commit:YES error:&error];
[calStore commit:nil];