Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EventKit: reminders dueDateComponents vs Alarm

I want to create a reminder from my app, so I've created a reminder (EKReminder) and set up an alarm:

NSTimeInterval timeInterval = 100000;
NSDate *alarmDate = [NSDate dateWithTimeIntervalSinceNow:timeInterval];
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:alarmDate];
[reminder setAlarms:@[alarm]];

but I see there is also a dueDateComponents property on EKReminder. What is the difference between setting an alarm and the dueDateComponents?

Also there there is a method to create an alarm: alarmWithRelativeOffset:(NSTimeInterval)offset but the docs say the offset argument can be negative, how is it possible to have an alarm in the past?

like image 909
Jonathan. Avatar asked Jan 03 '13 08:01

Jonathan.


2 Answers

a EKReminder item is kind of like a task on a todo list with an optional start date and due date, the dueDateComponents property allows you to specify when a task should be completed. It'll allow you to show overdue items for example. This is informational and is separate from an alarm.

Setting an alarm on a reminder will cause the Reminders app to notify the user when the alarm goes off.

I guess this is slightly confusing because the Reminders app doesn't appear to let you set a due date, only an alarm date. However on this blog post it shows how you used to be able to set a due date but no reminder date on icloud.com: http://blog.truthdialogue.com/2012/07/setting-due-dates-in-the-os-x-mountain-lion-reminders-app.html. It looks as if Apple have simplified the apps since the API was developed.

The offset for alarmWithRelativeOffset: is from the start date/time of an event. So you can set an alarm to go off x minutes before an event for example.

like image 78
Andrew Tetlaw Avatar answered Oct 20 '22 08:10

Andrew Tetlaw


let alarmist : EKAlarm = EKAlarm()
alarmist.relativeOffset = -0
reminder.addAlarm(alarmist)
NSLog("reminder has alarm ->" + reminder.hasAlarms.description)
like image 43
Larry Ricker Avatar answered Oct 20 '22 07:10

Larry Ricker