How to set a reminder (alarm) using the eventKit frame for a specific date

I work with EventKit framework in iOS 5, and I successfully added the event to the iOS calendar using the code below

EKEventStore *eventDB = [[EKEventStore alloc] init];

    EKEvent *myEvent  = [EKEvent eventWithEventStore:eventDB];

    myEvent.title     = @"New Event";
    myEvent.startDate = [[NSDate alloc] init];
    myEvent.endDate   = [[NSDate alloc] init];
    myEvent.allDay = YES;

    [myEvent setCalendar:[eventDB defaultCalendarForNewEvents]];

Now How do I add an alarm (reminder) for this event?

Thanks Ranjit

+5
source share
1 answer

By adding this code -

NSTimeInterval interval = 60* -min;

Where min is the time when you want to show a warning. this must be a negative value so that it is displayed (min) before your event.

EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:interval];
[myEvent addAlarm:alarm];

Enjoy !!!

+11
source

All Articles