EventKit - 添加带有2个警报的EKEvent时,应用程序冻结(iOS 5)

Gle*_*ett 5 iphone objective-c ios eventkit

我有一个应用程序,以编程方式添加提醒您的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]; 
Run Code Online (Sandbox Code Playgroud)

在iOS 5上,这会冻结应用程序.它不会返回错误 - 它永远不会返回.

如果我只调用一次addAlarm,它会按预期工作.

在iOS 4.2上,调用addAlarm两次工作正常.

难道我做错了什么?

Lou*_*uie 1

这是苹果的一个错误。如果您设置 2 个闹钟,则会导致应用程序冻结。如果你只设置 1,它就可以正常工作。这在 iOS 5.1 中已修复。