我想创建一个带有复杂规则的重复提醒,即
- (id)initRecurrenceWithFrequency:(EKRecurrenceFrequency)type interval:(NSInteger)interval daysOfTheWeek:(NSArray *)days daysOfTheMonth:(NSArray *)monthDays monthsOfTheYear:(NSArray *)months weeksOfTheYear:(NSArray *)weeksOfTheYear daysOfTheYear:(NSArray *)daysOfTheYear setPositions:(NSArray *)setPositions end:(EKRecurrenceEnd *)end
似乎很接近但据我所知,我认为我必须使用一系列事件。
我需要指示创建提醒的方向,这些提醒发生在特定时间 - >在特定的一周 - >在特定的开始日期和结束日期
谢谢
修改
我尝试过以下事情并遇到一些问题取得了一些成功
EKEvent *event = [EKEvent eventWithEventStore:kEVENTSTORE_SINGLTON];
event.title = @"Event Title test";
event.notes= @"Hope this one displays";
NSArray* rulesArray = [event recurrenceRules];
for (EKRecurrenceRule* rule in rulesArray) [event removeRecurrenceRule:rule];
event.startDate = [NSDate date]; //today
event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting
[event setCalendar:[kEVENTSTORE_SINGLTON defaultCalendarForNewEvents]];
NSDate *date = [NSDate date];
EKAlarm *alarm1 = [EKAlarm alarmWithAbsoluteDate:[date dateByAddingTimeInterval:60]];
// [event addAlarm:alarm1];
EKAlarm *arm=[EKAlarm alarmWithRelativeOffset:60];
EKAlarm *alarm2 = [EKAlarm alarmWithAbsoluteDate:[date dateByAddingTimeInterval:120]];
// [event addAlarm:alarm2];
EKAlarm *alarm3 = [EKAlarm alarmWithAbsoluteDate:[date dateByAddingTimeInterval:180]];
// [event addAlarm:alarm3];
EKAlarm *alarm4 = [EKAlarm alarmWithAbsoluteDate:[date dateByAddingTimeInterval:240]];
//[event addAlarm:alarm4];
EKRecurrenceRule *objRecurrenceRule=[[EKRecurrenceRule alloc]initRecurrenceWithFrequency:EKRecurrenceFrequencyWeekly interval:1 daysOfTheWeek:@[[EKRecurrenceDayOfWeek dayOfWeek:EKFriday]] daysOfTheMonth:nil monthsOfTheYear:nil weeksOfTheYear:nil daysOfTheYear:nil setPositions:nil end:[EKRecurrenceEnd recurrenceEndWithOccurrenceCount:1]];
//[event addRecurrenceRule:objRecurrenceRule];
event.recurrenceRules=@[objRecurrenceRule];
event.alarms=@[arm];//if i add the relative alarm it works if i add absolute alarm it dosnt.
NSError *err = nil;
[kEVENTSTORE_SINGLTON saveEvent:event span:EKSpanFutureEvents commit:YES error:&err];
if(err)
NSLog(@"some error occured");
所以我观察到,递归规则与相对警报一起工作,如果警报必须在每个星期五出现,则给出绝对警报
但是我的要求是我希望闹钟每个星期五响铃说下午5点的日期可以是相对的但是时间必须修复我怎么能达到这个目的?