我正在使用以下代码将事件添加到 iphone 的日历中,
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:eventStore];
event.title = @"title";
event.startDate = [NSDate date];
event.endDate = somedate;
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
[eventStore saveEvent:event span:EKSpanThisEvent error:&err];
并访问我使用的事件,
EKEventStore *eventStore = [[EKEventStore alloc] init];
NSPredicate *predicate = [eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:nil];
NSArray *eventsOfTheMonth = [eventStore eventsMatchingPredicate:predicate];
NSMutableArray *tempEKEvents = [NSMutableArray arrayWithCapacity:[eventsOfTheMonth count]];
for (EKEvent *event in eventsOfTheMonth) {
[tempEKEvents addObject:event];
}
}
出于某种原因,当我想向已经有 iCal 添加的事件的一天添加新事件时,该事件不会添加。但它会将事件添加到其他任何一天,即使是那些通过我的应用程序添加了多个事件的事件。