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?
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.
let alarmist : EKAlarm = EKAlarm()
alarmist.relativeOffset = -0
reminder.addAlarm(alarmist)
NSLog("reminder has alarm ->" + reminder.hasAlarms.description)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With