【发布时间】:2011-11-15 18:34:56
【问题描述】:
eventStore=[[EKEventStore alloc] init];
EKEvent *addEvent=[EKEvent eventWithEventStore:eventStore];
addEvent.title=@"hello";
addEvent.startDate=messageDate;
addEvent.endDate=[addEvent.startDate dateByAddingTimeInterval:600];
[addEvent setCalendar:[eventStore defaultCalendarForNewEvents]];
addEvent.alarms=[NSArray arrayWithObject:[EKAlarm alarmWithAbsoluteDate:addEvent.startDate]];
[eventStore saveEvent:addEvent span:EKSpanThisEvent error:nil];
上面的代码在 ios 4.2 中运行良好,但在 ios 5 中不行。我在 applicationDidfinishingLaunching 方法中有代码。由于错误,出现黑屏并退出应用程序。只有recurrenceRules 在ios 5 中发生了变化,我没有使用它。所有其他属性都在超类 EKCalendarItem 中可用。我无法测试它,因为我有 xcode 3.2 和雪豹。我正在寻找调试导致应用程序退出的错误发生的行。我怀疑它与 setCalendar 或使用警报属性有关。
【问题讨论】:
-
它工作完美:)