Question

I'm currently trying to write a method to compare EKAlarms to one another. The problem with this is between absoluteDate and relativeOffset. Comparing two alarms each with an absoluteDate is easy, but if one or both have a relativeOffset, you need to know what event they're relatively offset from. As per the documentation,

relativeOffset: The offset from the start of an event, at which the alarm fires.

Yet, I see no documentation on setting the trigger for a relativeOffset alarm. Can anyone help me figure out what I'm missing? How can I compare two EKAlarms with relativeOffsets?

Thanks for the help!

Was it helpful?

Solution

As you rightly say:

if one or both have a relativeOffset, you need to know what event they're relatively offset from

Quite so. But how can you possibly not know that? EKAlarms do not float around loose, falling from the sky like snowflakes. If not attached to an EKCalendarItem, a relative EKAlarm is meaningless; there is nothing to compare. If it is attached to an EKCalendarItem, then you clearly know that fact - otherwise, where would you have gotten the alarm from??? Either you just created the alarm, and are about to attach it to an EKCalendarItem yourself, or you have started with the EKCalendarItem and have looked at its alarms property, in which case you also know the EKCalendarItem's startDate and can calculate from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top