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?

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Glenn Barnett
  • 2,031
  • 1
  • 21
  • 31

4 Answers4

1

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 .

Glenn Barnett
  • 2,031
  • 1
  • 21
  • 31
Louie
  • 5,920
  • 5
  • 31
  • 45
0

have you tried calling addAlarm using a variable?

EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:60.0f * -5.0f]]; // 5 min
[event addAlarm:alarm];

EKAlarm *alarm2 = [EKAlarm alarmWithRelativeOffset:60.0f * -15.0f]]; // 15 min
[event addAlarm:alarm2];
zakishaheen
  • 5,551
  • 1
  • 22
  • 29
Jimmy
  • 1
0

If you take a look at the EventKit section in the iOS 5 changes from iOS 4.3 document, it mentions that some items are deprecated for EKEvent. The hierarchy has changed and a new abstract superclass has been added: EKCalendarItem.

ruxy
  • 282
  • 3
  • 9
  • What he wants to do should still work though. The alarm-related methods just got moved to EKCalendarItem. Nothing alarm-related got removed or deprecated. – Adrian Schönig Nov 02 '11 at 01:42
  • Exactly. I haven't tried using the new class hierarchy as a "workaround". If my bug report to Apple gets no traction, I'll give it a try and let you know what happens. – Glenn Barnett Nov 09 '11 at 14:45
0

I had the same error.

The problem seems that startDate shoudln't be the same as endDate... really silly iOS change!

phy
  • 31
  • 1
  • 1
    I ran into that as well, but even with that fixed, I CAN add a calendar item with one alarm, but it freezes if I've added two alarms. – Glenn Barnett Nov 09 '11 at 14:44