views:

32

answers:

1

Hi all I am using below code to create an event :

EKEvent *oneLabEvent = [EKEvent eventWithEventStore:eventStore];

oneLabEvent.calendar = eventStore.defaultCalendarForNewEvents;
oneLabEvent.title = [ddEvent valueForKey:@"ddname"];
oneLabEvent.allDay = NO;

oneLabEvent.startDate = [ddEvent valueForKey:@"startDate"];
oneLabEvent.endDate = [ddEvent valueForKey:@"endDate"];


//setting the alarm for the event

EKAlarm * alarm = [EKAlarm alarmWithRelativeOffset:0];
oneLabEvent.alarms = [NSArray arrayWithObject:alarm];

//setting the Reuccurence rule
EKRecurrenceRule * recurrenceRule = [[EKRecurrenceRule alloc] 
                                     initRecurrenceWithFrequency:EKRecurrenceFrequencyMonthly
                                     interval:1
                                     end:nil];
if (oneLabEvent.endDate != nil) {
    EKRecurrenceEnd * end = [EKRecurrenceEnd recurrenceEndWithEndDate:oneLabEvent.endDate];
    recurrenceRule.recurrenceEnd = end;
}else {
    oneLabEvent.endDate = oneLabEvent.startDate;
}



oneLabEvent.recurrenceRule = recurrenceRule;
[recurrenceRule release];

NSError *error;

BOOL saved = [eventStore saveEvent:oneLabEvent span:EKSpanThisEvent error:&error];
if (!saved && error) {
    NSLog(@"Error while saving the event:%@",[error localizedDescription]);
}

[ddEvent setValue:oneLabEvent.eventIdentifier forKey:@"eventID"];

in my phone it works like a charm but when a friend in his iphone tries modifications to the event He gets this error .

alt text

Now can anyone tell me that is anything wrong with my code or is there any calendar settings that can be different from my phone and friend phone .

+2  A: 

Your start end end dates are from different years. 14th August is a Saturday this year, but your end date shows Moday for 14th August.

So it is from another year, making it longer than one month, which is your repeat interval.

Eiko
yes I have checked that but when I do the same settings in my phone it doesn't trigger any error and accepts as it is .
hib
The dates are wrong... and they must come from somewhere. Your repeat section shows that 14th Aug 2023 is a Monday. Maybe this is related and you somehow managed to populate the event.endDate with that value.
Eiko