I wrote the following snippet to create an event. Setting the alarm works fine in iOS 4, but it is not installed in iOS 5. Is this a mistake or am I missing something?
EKCalendar *cal = [self.eventStore defaultCalendarForNewEvents]; EKEvent *event = [EKEvent eventWithEventStore:self.eventStore]; event.calendar = cal; // ....... EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-3600]; event.alarms = [NSArray arrayWithObject:alarm]; // .......
I had the same error.
The problem seems to be that startDate will not be the same as endDate ... a really stupid iOS change!
It seems that this is due to what is happening on this ticket: EventKit - the application freezes when adding an EKEvent with 2 signals (iOS 5) .
If you look at the EventKit section in iOS 5 changes from an iOS 4.3 document, it mentions that some elements are deprecated for EKEvent. The hierarchy has changed and a new abstract superclass has been added: EKCalendarItem .
Avoid manipulating an accident array. You need to add an alarm to your event as follows:
EKAlarm *reminder = [EKAlarm alarmWithRelativeOffset:-300]; [event addAlarm:reminder];
This will add a reminder 5 minutes before the start.