eventStore=[[EKEventStore alloc] init];
EKEvent *addEvent=[EKEvent eventWithEventStore:eventStore];
addEvent.title=@"hello";
addEvent.startDate=messageDate;
addEvent.endDate=[addEvent.startDate dateByAddingTimeInterval:600];
[addEvent setCalendar:[eventStore defaultCalendarForNewEvents]];
addEvent.alarms=[NSArray arrayWithObject:[EKAlarm alarmWithAbsoluteDate:addEvent.startDate]];
[eventStore saveEvent:addEvent span:EKSpanThisEvent error:nil];
The code above works fine in ios 4.2 but not in ios 5. I have the code in applicationDidfinishingLaunching method. Due to error, black screen appears and app exits. Only recurrenceRules has changed in ios 5 and I have not made use of it. All other properties are available in superclass EKCalendarItem. I cannot test it since I have xcode 3.2 and snow leopard. I am looking to debug the line at which error occurs causing the app to quit. I doubt it is related to setCalendar or using alarms property.
The code is correct and works in iOS 5. The reason for my error was the first line
Since initializing eventstore takes some time, placing it in application launch method resulted in time out. I found it from my crash report stating:
The app is supposed to launch within 10 seconds. if not time out occurs with
Exception Codes: 0x8badf00d