このコードを使用してデバイスにイベントを追加していますが、デバイスのカレンダーでは、イベントの終了日までの各日付に表示されます
NSString *GoalDate = [[[DFDateFormatterFactory sharedFactory]
dateFormatterWithFormat:@"yyyy-MM-dd" andLocaleIdentifier:@"en_US"]
stringFromDate:self.datepicker.date];
[AppHelper saveToUserDefaults:GoalDate withKey:@"goalsdates"];
NSInteger dummyInteger = [[AppHelper userDefaultsForKey:@"event"]intValue];
if(dummyInteger!=0)
{
[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
if (!granted)
{ return;
}
EKRecurrenceEnd *endRecurrence = nil;
endRecurrence = [EKRecurrenceEnd recurrenceEndWithEndDate:self.datepicker.date];
EKRecurrenceRule *recurrence;
if(dummyInteger==1)
{
recurrence= [[EKRecurrenceRule alloc] initRecurrenceWithFrequency: EKRecurrenceFrequencyDaily
interval:1 daysOfTheWeek:nil daysOfTheMonth:nil monthsOfTheYear:nil weeksOfTheYear:nil daysOfTheYear:nil setPositions:nil end:endRecurrence];
}
if(dummyInteger==2)
{
recurrence = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency: EKRecurrenceFrequencyWeekly interval:7 daysOfTheWeek:nil daysOfTheMonth:nil monthsOfTheYear:nil weeksOfTheYear:nil daysOfTheYear:nil setPositions:nil
end:endRecurrence];
}
if(dummyInteger==3)
{
recurrence = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency: EKRecurrenceFrequencyWeekly interval:1 daysOfTheWeek:nil daysOfTheMonth:nil monthsOfTheYear:nil weeksOfTheYear:nil daysOfTheYear:nil setPositions:nil end:endRecurrence];
}
if(dummyInteger==4)
{
recurrence = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency: EKRecurrenceFrequencyYearly interval:1 daysOfTheWeek:nil daysOfTheMonth:nil monthsOfTheYear:nil weeksOfTheYear:nil daysOfTheYear:nil setPositions:nil end:endRecurrence];
}
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = [AppHelper userDefaultsForKey:@"nameofagoal"];
event.allDay = false;
event.startDate =[NSDate date];
// event.endDate = [event.startDate dateByAddingTimeInterval:60*60*24*7]; //set 1 hour meeting
event.endDate = self.datepicker.date;
// event.endDate = endDate;
[event setCalendar:[store defaultCalendarForNewEvents]];
NSError *err = nil;
[event addRecurrenceRule: recurrence];
[store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
savedEventId = event.eventIdentifier; //this is so you can access this event later
}];