EKRecurrenceRule Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/EventKit.framework
Availability
Available in OS X v10.8 and later.
Companion guide
Declared in
EKRecurrenceRule.h
EKTypes.h

Overview

The EKRecurrenceRule class is used to describe the recurrence pattern for a recurring event.

After you create a recurrence rule, assign it to an event with the recurrenceRule method of EKEvent.

Recurrence rules can have an end, represented by an EKRecurrenceEnd object. The end can be based on a specific date or a maximum number of occurrences.

Tasks

Creating a Basic Recurrence Rule

Creating a Complex Recurrence Rule

Accessing Recurrence Rule Properties

Properties

calendarIdentifier

The identifier for the recurrence rule’s calendar. (read-only)

@property(readonly) NSString *calendarIdentifier
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

daysOfTheMonth

The days of the month associated with the recurrence rule, as an array of NSNumber objects. Values can be from 1 to 31 and from -1 to -31.This property value is valid only for recurrence rules that were initialized with specific days of the month and a frequency type of EKRecurrenceFrequencyMonthly. (read-only)

@property(readonly) NSArray *daysOfTheMonth
Discussion

Negative values indicate counting backwards from the end of the month.

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

daysOfTheWeek

The days of the week associated with the recurrence rule, as an array of EKRecurrenceDayOfWeek objects. This property value is valid only for recurrence rules that were initialized with specific days of the week and a frequency type of EKRecurrenceFrequencyWeekly, EKRecurrenceFrequencyMonthly, or EKRecurrenceFrequencyYearly. (read-only)

@property(readonly) NSArray *daysOfTheWeek
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

daysOfTheYear

The days of the year associated with the recurrence rule, as an array of NSNumber objects. Values can be from 1 to 366 and from -1 to -366. This property value is valid only for recurrence rules initialized with a frequency type of EKRecurrenceFrequencyYearly. (read-only)

@property(readonly) NSArray *daysOfTheYear
Discussion

Negative values indicate counting backwards from the end of the year.

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

firstDayOfTheWeek

Indicates which day of the week the recurrence rule treats as the first day of the week. Values of 1 to 7 correspond to Sunday through Saturday. A value of 0 indicates that this property is not set for the recurrence rule. (read-only)

@property(readonly) NSInteger firstDayOfTheWeek
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

frequency

The frequency of the recurrence rule. (read-only)

@property(readonly) EKRecurrenceFrequency frequency
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

interval

Specifies how often the recurrence rule repeats over the unit of time indicated by its frequency. For example, a recurrence rule with a frequency type of EKRecurrenceFrequencyWeekly and an interval of 2 repeats every two weeks. (read-only)

@property(readonly) NSInteger interval
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

monthsOfTheYear

The months of the year associated with the recurrence rule, as an array of NSNumber objects. Values can be from 1 to 12. This property value is valid only for recurrence rules initialized with specific months of the year and a frequency type of EKRecurrenceFrequencyYearly. (read-only)

@property(readonly) NSArray *monthsOfTheYear
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

recurrenceEnd

Indicates when the recurrence rule ends. This can be represented by an end date or a number of occurrences.

@property(copy) EKRecurrenceEnd *recurrenceEnd
Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

setPositions

An array of ordinal numbers that filters which recurrences to include in the recurrence rule’s frequency. For example, a yearly recurrence rule that has a daysOfTheWeek value that specifies Monday through Friday, and a setPositions array containing 2 and -1, occurs only on the second weekday and last weekday of every year. (read-only)

@property(readonly) NSArray *setPositions
Discussion

Values can be from 1 to 366 and from -1 to -366.

Negative values indicate counting backwards from the end of the recurrence rule’s frequency (week, month, or year).

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

weeksOfTheYear

The weeks of the year associated with the recurrence rule, as an array of NSNumber objects. Values can be from 1 to 53 and from -1 to -53. This property value is valid only for recurrence rules initialized with specific weeks of the year and a frequency type of EKRecurrenceFrequencyYearly. (read-only)

@property(readonly) NSArray *weeksOfTheYear
Discussion

Negative values indicate counting backwards from the end of the year.

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

Instance Methods

initRecurrenceWithFrequency:interval:daysOfTheWeek:daysOfTheMonth:monthsOfTheYear:weeksOfTheYear:daysOfTheYear:setPositions:end:

Initializes and returns a recurrence rule with a given frequency and additional scheduling information.

- (id)initRecurrenceWithFrequency:(EKRecurrenceFrequency)type interval:(NSInteger)interval daysOfTheWeek:(NSArray *)days daysOfTheMonth:(NSArray *)monthDays monthsOfTheYear:(NSArray *)months weeksOfTheYear:(NSArray *)weeksOfTheYear daysOfTheYear:(NSArray *)daysOfTheYear setPositions:(NSArray *)setPositions end:(EKRecurrenceEnd *)end
Parameters
type

The frequency of the recurrence rule. Can be daily, weekly, monthly, or yearly.

interval

The interval between instances of this recurrence. For example, a weekly recurrence rule with an interval of 2 occurs every other week. Must be greater than 0.

days

The days of the week that the event occurs, as an array of EKRecurrenceDayOfWeek objects.

monthDays

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.

months

The months of the year that the event occurs, as an array of NSNumber objects. Values can be from 1 to 12. This parameter is only valid for recurrence rules of type EKRecurrenceFrequencyYearly.

weeksOfTheYear

The weeks of the year that the event occurs, as an array of NSNumber objects. Values can be from 1 to 53 and from -1 to -53. This parameter is only valid for recurrence rules of type EKRecurrenceFrequencyYearly.

daysOfTheYear

The days of the year that the event occurs, as an array of NSNumber objects. Values can be from 1 to 366 and from -1 to -366. This parameter is only valid for recurrence rules of type EKRecurrenceFrequencyYearly.

setPositions

An array of ordinal numbers that filters which recurrences to include in the recurrence rule’s frequency. See setPositions for more information.

end

The end of the recurrence rule.

Return Value

The initialized recurrence rule, or nil if invalid values are provided.

Discussion

Negative values indicate counting backwards from the end of the recurrence rule’s frequency.

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

initRecurrenceWithFrequency:interval:end:

Initializes and returns a simple recurrence rule with a given frequency, interval, and end.

- (id)initRecurrenceWithFrequency:(EKRecurrenceFrequency)type interval:(NSUInteger)interval end:(EKRecurrenceEnd *)end
Parameters
type

The frequency of the recurrence rule. Can be daily, weekly, monthly, or yearly.

interval

The interval between instances of this recurrence. For example, a weekly recurrence rule with an interval of 2 occurs every other week. Must be greater than 0.

end

The end of the recurrence rule.

Return Value

The initialized recurrence rule, or nil if invalid values are provided.

Availability
  • Available in OS X v10.8 and later.
Declared In
EKRecurrenceRule.h

Constants

EKRecurrenceFrequency

Defines frequencies for recurrence rules.

typedef enum {
   EKRecurrenceFrequencyDaily,
   EKRecurrenceFrequencyWeekly,
   EKRecurrenceFrequencyMonthly,
   EKRecurrenceFrequencyYearly
} EKRecurrenceFrequency;
Constants
EKRecurrenceFrequencyDaily

Indicates a daily recurrence rule.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKRecurrenceFrequencyWeekly

Indicates a weekly recurrence rule.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKRecurrenceFrequencyMonthly

Indicates a monthly recurrence rule.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKRecurrenceFrequencyYearly

Indicates a yearly recurrence rule.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

Days of the Week

Defines values for the days of the week.

enum {
   EKSunday = 1,
   EKMonday,
   EKTuesday,
   EKWednesday,
   EKThursday,
   EKFriday,
   EKSaturday
};
Constants
EKSunday

The value for Sunday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKMonday

The value for Monday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKTuesday

The value for Tuesday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKWednesday

The value for Wednesday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKThursday

The value for Thursday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKFriday

The value for Friday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.

EKSaturday

The value for Saturday.

Available in OS X v10.8 and later.

Declared in EKTypes.h.