I am creating simple application that has ability to add events into iPhone Calendar. So I am playing with EKEvent’s recurrenceRule. There is a class EKRecurrenceRule with very long constructor:
(id)initRecurrenceWithFrequency:(EKRecurrenceFrequency)
typeinterval:(NSInteger)interval
daysOfTheWeek:(NSArray *)days
daysOfTheMonth:(NSArray *)monthDays
monthsOfTheYear:(NSArray *)months
weeksOfTheYear:(NSArray *)weeksOfTheYear
daysOfTheYear:(NSArray*)daysOfTheYear
setPositions:(NSArray *)setPositions
end:(EKRecurrenceEnd*)end
So for example, if I am trying to create a event that will be repeated every work day in the week (except Sunday), I will use this init:
initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily
interval:1
daysOfTheWeek:[NSArray arrayWithObjects:
[EKRecurrenceDayOfWeek dayOfWeek:2],
[EKRecurrenceDayOfWeek dayOfWeek:3],
[EKRecurrenceDayOfWeek dayOfWeek:4],
[EKRecurrenceDayOfWeek dayOfWeek:5],
[EKRecurrenceDayOfWeek dayOfWeek:6],
[EKRecurrenceDayOfWeek dayOfWeek:7], nil]
daysOfTheMonth:nil
monthsOfTheYear:nil
weeksOfTheYear:nil
daysOfTheYear:nil
setPositions:nil
end:nil
but it is not working, it just repeat event every day :S
When I try use EKRecurrenceFrequencyMonthly, then it works. It repeats event every month, but not on Sunday. I reported bug to Apple, because it seems that they have a bug.
Or you have other idea?
Apple documentation says:
@method initRecurrenceWithFrequency:interval:daysOfTheWeek:daysOfTheMonth:monthsOfTheYear:weeksOfTheYear:daysOfTheYear:setPositions:end:
@abstract The designated initializer.
@discussion This can be used to build any kind of recurrence rule. But be aware that certain combinations make no sense and will be ignored. For example, if you pass daysOfTheWeek for a daily recurrence, they will be ignored.
I think, we can’t say it daily and say not on Sunday. Please let me know if I am mistaken.
Thanks.