Recurring events are events that repeat daily, weekly, monthly, or yearly. The pattern that repeats can be complex. For example, you might schedule an event every Tuesday and Thursday of the first and second week of every month of the year.
You make an event a recurring event by assigning it a recurrence rule, which describes when the event occurs. Recurrence rules are represented by instances of the EKRecurrenceRule
class.
You can create a recurrence rule with a simple daily, weekly, monthly, or yearly pattern with the initRecurrenceWithFrequency:interval:end:
method. You provide three values to this method:
The recurrence frequency. This is a value of type EKRecurrenceFrequency
that indicates whether the recurrence rule is daily, weekly, monthly, or yearly.
The recurrence interval. This is an integer greater than 0 that specifies how often a pattern repeats. For example, if the recurrence rule is a weekly recurrence rule and its interval is 1, then the pattern repeats every week. If the recurrence rule is a monthly recurrence rule and its interval is 3, then the pattern repeats every three months.
The recurrence end. This optional parameter is an instance of the EKRecurrenceEnd
class, which indicates when the recurrence rule ends. The recurrence end can be based on a specific end date or on a number of occurrences.
If you don’t want to specify an end for the recurrence rule, pass nil
.
You can create a recurrence rule with a complex pattern with the initRecurrenceWithFrequency:interval:daysOfTheWeek:daysOfTheMonth:monthsOfTheYear:weeksOfTheYear:daysOfTheYear:setPositions:end:
method. As you do for a basic recurrence rule, you provide a frequency, an interval, and an optional end for the recurrence. In addition, you can provide the following values:
Days of the week. For all recurrence rules besides daily recurrence rules, you can provide an array of EKRecurrenceDayOfWeek
objects that indicate the days of the week on which the event occurs.
For example, you can provide an array containing EKRecurrenceDayOfWeek
objects with day of week values of EKTuesday
and EKFriday
to create a recurrence that occurs every Tuesday and Friday.
Days of the month. For monthly recurrence rules only, you can provide an array of NSNumber
objects that indicate the days of the month on which the event occurs. Values can be from 1 to 31, and from –1 to –31. Negative values indicate counting backward from the end of the month.
For example, you can provide an array containing the values 1 and –1 to create a recurrence that occurs on the first and last day of every month.
Months of the year. For yearly recurrence rules only, you can provide an array of NSNumber
objects that indicate the months of the year in which the event occurs. Values can be from 1 to 12.
For example, if your originating event occurs on January 10, you can provide an array containing the values 1 and 2 to create a recurrence that occurs every January 10 and February 10.
Weeks of the year. For yearly recurrence rules only, you can provide an array of NSNumber
objects that indicate the weeks of the year in which the event occurs. Values can be from 1 to 53, and from –1 to –53. Negative values indicate counting backward from the end of the year.
For example, if your originating event occurs on a Wednesday, you can provide an array containing the values 1 and –1 to create a recurrence that occurs on the Wednesday of the first and last weeks of every year. If a specified week does not contain a Wednesday in the current year, as can be the case for the first or last week of a year, the event does not occur.
Days of the year. For yearly recurrence rules only, you can provide an array of NSNumber
objects that indicate the days of the year on which the event occurs. Values can be from 1 to 366, and from –1 to –366. Negative values indicate counting backward from the end of the year.
For example, you can provide an array containing the values 1 and –1 to create a recurrence that occurs on the first and last day of every year.
Set positions. For all recurrence rules besides daily recurrence rules, you can provide an array of NSNumber
objects that filters which occurrences to include in the recurrence rule. This filter is applied to the set of occurrences determined from the other parameters you provide. Values can be from 1 to 366, and from –1 to –366. Negative values indicate counting backward from the end of the list of occurrences.
For example, you can provide an array containing the values 1 and –1 to a yearly recurrence rule that has specified Monday through Friday as its value for days of the week, and the recurrence occurs only on the first and last weekday of every year.
You can provide values for any number of the above parameters (parameters that don’t apply to a particular recurrence rule are ignored). If you provide a value for more than one of the above parameters, the recurrence occurs only on days that apply to all provided values.
Last updated: 2010-08-03