Search code examples
iosswiftrecurrenceekeventstore

Best way to see a EkReminder recurrence frequency?


When loading a reminder from the EKEventStore, what is the best way to determine what type of recurrence frequency the reminder has?

So far I have been able to see if the reminder contains a recurrenceRule using:

if reminder.hasRecurrenceRules {
  if true {
    print("Reminder has recurrence rule")
  }
}

But as this only returns a boolean. I was wondering how best I can return a reminders recurrence frequency (i.e. if the recurrence rule is .daily or .weekly). Do I need to use a different method and if so, how?

I’m a complete rookie at this so I hope some of this makes sense, I could be completely off the ball…

I really appreciate any help and guidance! Thank you!


Solution

  • Every EKCalendarItem has an array of recurrence rules recurrenceRules, instances of EKRecurrenceRule

    Therefore, you can check for example:

    if let recurrenceRule = reminder.recurrenceRules.first {
       if recurrenceRule.frequence == .daily {
          // do something
       }
    }