dmeads89
dmeads89

Reputation: 89

EKRecurrenceRule not working

I have followed a number of tutorials and looked at the documentation and think I have the right code however it still doesn't want to recur. Any ideas would be very appreciated. The code I have is below. Thanks.

 EKRecurrenceEnd *endRecurrence = [EKRecurrenceEnd recurrenceEndWithOccurrenceCount:14];

    EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 end:endRecurrence];

    NSMutableArray *rules = [[NSMutableArray alloc] init];

    [rules arrayByAddingObject:rule];

    event.recurrenceRules = rules; 

Upvotes: 1

Views: 2386

Answers (1)

hokkuk
hokkuk

Reputation: 675

I believe the way you do it is like so: (i've added a case where if you want to get rid of any rules that exist already)

NSArray* rulesArray = [event recurrenceRules];

for (EKRecurrenceRule* rule in rulesArray) [event removeRecurrenceRule:rule];

EKRecurrenceEnd *endRecurrence = [EKRecurrenceEnd recurrenceEndWithOccurrenceCount:14];

    EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 end:endRecurrence];

    [event addRecurrenceRule:rule]; 

    [rule release];

then just add another one if it is required

Upvotes: 4

Related Questions