How to set a reminder(alarm) using eventKit framework for a particular date

岁酱吖の 提交于 2019-12-06 02:08:05

问题


I am working with EventKit framework in iOS 5 and I successfully added an event to the iOS calendar using the below code

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 shall i added an alarm (reminder) for this event ?

Thanks Ranjit


回答1:


By Adding this code -

NSTimeInterval interval = 60* -min;

Where min is the time when you want to show alert. this should be a negative value so that this will appear (min) before of your event.

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

Enjoy!!!



来源:https://stackoverflow.com/questions/8270117/how-to-set-a-reminderalarm-using-eventkit-framework-for-a-particular-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!