0

I am trying to represent the recurrence rule,

Every 4 years only on 4th of July.

like this:

termin.addRecurrenceRule(EKRecurrenceRule(recurrenceWithFrequency: .Yearly,
    interval: 4,
    daysOfTheWeek: nil,
    daysOfTheMonth: [NSNumber(int: 4)],
    monthsOfTheYear: [NSNumber(int :7)],
    weeksOfTheYear: nil,
    daysOfTheYear: nil,
    setPositions: nil,
    end: nil))

but Apple documentation says:

daysOfTheMonth: The days of the month that the event occurs, as an array of NSNumber objects. Values can be from 1 to 31 and from -1 to -31. This parameter is only valid for recurrence rules of type EKRecurrenceFrequencyMonthly.

Then how can I represent the above mentioned rule with the EKRecurrenceRule class?

NB: The answers could be in Swift or Objc.

Goppinath
  • 10,569
  • 4
  • 22
  • 45

1 Answers1

1

Create an event with a start and end date on the 4th of July and give it a yearly recurrence rule like this:

let event = EKEvent(eventStore: self.eventStore)

event.title = title
event.startDate = fourthOfJulyStartDate
event.endDate = fourthOfJulyEndDate
event.recurrenceRules = [EKRecurrenceRule(recurrenceWithFrequency: .Yearly, interval: 4, end: nil)]
Dustin Spengler
  • 5,478
  • 4
  • 28
  • 36