Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EventKit - App freezes when adding an EKEvent with 2 alarms (iOS 5)

I have an app that programmatically adds reminders to your iOS device's calendar.

Previous to iOS 5, I could add a calendar item with two alarms thusly:

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]; 

On iOS 5 this freezes the application. It does not return with an error - it just never returns.

If I only call addAlarm once, it works as expected.

On iOS 4.2, calling addAlarm twice works just fine.

Am I doing something wrong?

like image 322
Glenn Barnett Avatar asked Nov 13 '22 15:11

Glenn Barnett


1 Answers

Its a bug with Apple. If you set 2 alarms it causes the app to freeze. If you only set 1 it works just fine. This is fixed in iOS 5.1 .

like image 102
Louie Avatar answered May 16 '23 09:05

Louie