【发布时间】:2011-10-21 02:39:32
【问题描述】:
我有一个应用程序以编程方式将提醒添加到您的 iOS 设备的日历中。
在 iOS 5 之前,我可以添加一个带有两个闹钟的日历项:
EKEventStore* eventStore = [[EKEventStore alloc] init];
EKEvent* event = [EKEvent eventWithEventStore:eventStore];
// set startDate, endDate, title, location, etc.
[event addAlarm:[EKAlarm alarmWithRelativeOffset:60.0f * -5.0f]]; // 5 min
[event addAlarm:[EKAlarm alarmWithRelativeOffset:60.0f * -15.0f]]; // 15 min
[event setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError* error = nil;
BOOL success = [eventStore saveEvent:event span:EKSpanThisEvent error:&error];
在 iOS 5 上,这会冻结应用程序。它不会返回错误 - 它永远不会返回。
如果我只调用一次 addAlarm,它会按预期工作。
在 iOS 4.2 上,调用 addAlarm 两次就可以了。
我做错了吗?
【问题讨论】:
-
仅供参考,我已经向 Apple 提交了一个错误;当我听到更多消息时会更新这篇文章。
-
是的 - 它已在 5.1b2 中修复。我已经在朋友的设备上确认了这一点。
标签: iphone objective-c ios eventkit