大家好我在下面的代码中创建一个事件:
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"];
在我的手机中,它就像一个魅力,但当他的iphone中的朋友尝试修改事件时,他会收到此错误。
alt text http://img208.imageshack.us/img208/8850/photot.png
现在有人可以告诉我,我的代码有问题,或者是否有任何日历设置可能与我的手机和朋友手机不同。
答案 0 :(得分:2)
您的开始结束日期来自不同年份。 8月14日是今年的星期六,但结束日期显示8月14日 Moday 。
所以它是从另一年开始,超过一个月,这是你的重复间隔。