如何使用我的应用程序设置提醒?

时间:2014-10-16 09:07:37

标签: ios objective-c

我已经在MBCalender工具包的帮助下创建了自定义日历,现在我已经为某些特定日期添加了活动,如何为这些特定日期创建提醒?

1 个答案:

答案 0 :(得分:0)

使用EKReminder

- (void)createReminder:(NSDate*) objDate {
    EKReminder *reminder = [EKReminder
                            reminderWithEventStore:objEventStore];

    // objEventStore is the object of EKEventStore if you create that global that will be good

    reminder.title = @"title";
    reminder.notes = @"note";

    reminder.calendar = [objAppDelegate.eventStore defaultCalendarForNewReminders];

    EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:objDate];

    [reminder addAlarm:alarm];

    NSError *error = nil;

    BOOL status  = [objAppDelegate.eventStore saveReminder:reminder commit:YES error:&error];
    if (status == NO) {
        _strUDID = nil;
    }
    else  {
        _strUDID = [NSMutableString stringWithFormat:@"%@",reminder.calendarItemIdentifier];
    }

}