0

我需要使用 EventKit 在特定日期和时间添加一些事件。例如,我想添加 2012 年 9 月 2 日下午 1:00 的事件。

如果哪位知道的解释一下。

4

1 回答 1

0

要指定特定日期,您应该使用日期组件:

NSCalendar *greg = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [[NSDateComponents alloc] init];
comps.day = 2;
comps.month = 9;
comps.year = 2012;
comps.hour = 13;

NSDate *eventDate = [greg dateFromComponents:comps];

要通过 EventKit 添加事件,请使用eventWithEventStore:并修改属性startDate

于 2012-08-16T12:12:11.253 回答