简体   繁体   English

使用重复规则将EKAlarm添加到EKReminder

[英]Adding an EKAlarm to EKReminder with a recurrence rule

I have a quick question for someone familiar with Event Kit... 对于熟悉Event Kit的人,我有一个简单的问题...

I'm creating recurring reminders and I'd like an alarm to sound at each recurrence. 我正在创建定期提醒,我想在每次重复时发出警报。 However, the documentation suggests I can only create an alarm with an absolute date or a relative offset. 但是,文档建议我只能创建一个具有绝对日期或相对偏移量的警报。 Is there any way to get an alarm to fire every time the reminder reoccurs? 每次提醒重新出现时,有什么方法可以触发警报吗? Does it do this automatically? 它会自动执行此操作吗?

Thanks! 谢谢!

Since EKReminder is a subclass of EKCalendarItem you can use the addRecurrenceRule: method to add a recurrence rule so the reminder repeats. 由于EKReminderEKReminder的子类, EKCalendarItem您可以使用addRecurrenceRule:方法添加重复规则,以便重复提醒。 Unfortunately, you can't create a recurring alarm since the relative offset alarm is based on the start date of the reminder, and not the date of each recurring reminder. 遗憾的是,您无法创建定期警报,因为相对偏移警报基于提醒的开始日期,而不是每个定期提醒的日期。 However, you can add multiple EKAlarm 's to your EKReminder object so if your event repeats a discrete number of times, you could add an alarm for each. 但是,您可以将多个EKAlarm添加到EKReminder对象中,这样如果您的事件重复一次,您可以为每个事件添加一个警报。 If it repeats forever, you may be out of luck since Apple's docs say: 如果它永远重复,你可能会因为Apple的文档说:

Be warned that some calendars can only allow a certain maximum number of alarms. 请注意,某些日历只能允许一定数量的警报。 When this item is saved, it will truncate any extra alarms from the array. 保存此项目时,它将截断阵列中的任何额外警报。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM