EKRecurrenceRule with end repeat never

2019-04-14 19:53发布

问题:

I want to create a EKEvent in calendar with forever repeat option. Below is the code for the Recurrence rule

  EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] 
                            initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily 
                            interval:1
                            end:[EKRecurrenceEnd recurrenceEndWithEndDate:date]];

how to set infinite or never end in recurrence end argument.

Thanks

回答1:

little late, but i 'll answer, because i could not find the answer anywhere in the Apple Doc. Just pass nil as end param and there you go. Calender sets the end of the event to infinite.

EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] 
                        initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily 
                        interval:1
                        end:[EKRecurrenceEnd recurrenceEndWithEndDate:nil]];

The calender creates recurrence events for 2 years and then adds them on demand.

greets



回答2:

EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] 
                        initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily 
                        interval:1
                        end:nil];

just pass nil to the end so that it repeats all over. Have a happy Coding.