如何识别 EKEvent 中的 EKAlarm
我正在开发一个应用程序,需要相应地设置和删除警报。我想知道如果我为 EKEvent 设置了警报,当我想要删除它时如何识别它?
EKAlarm 唯一可访问的属性是absoluteDate 和relativeOffset。我觉得如果我设置的警报与不同用户生成的警报具有相同的relativeOffset或absoluteDate,则会导致问题。
有什么建议吗?
I'm developing an app that will require setting and removing alarms accordingly. I'm wondering if I set an alarm for an EKEvent, how can I identify it when I want to remove it?
The only accessible properties of the EKAlarm are absoluteDate and relativeOffset. I feel like it would cause problems if the alarm I set has the same relativeOffset or absoluteDate as a different user generated alarm.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果有两个警报具有相同的绝对日期,则仅删除其中一个似乎完全可以接受,因为它们本质上是重复的。
If there are two alarms that have the same absoluteDate, it seems perfectly acceptable to just remove one or the other, they are essentially duplicates.
只是一个想法,但您可能希望序列化您的事件并将其保存到某个持久存储中,然后,当您需要删除它时,反序列化它并删除该确切的事件。
这假设您想要在多个应用程序启动之间添加和删除事件,并且用户不会手动修改您的事件(不知道是否可能,但仍然如此)。
另外,从我在文档中看到的内容来看,EKEvent 的属性比您列出的两个要多得多。
EKEvent 类参考
Just an idea but you may want to serialize your event and save it to some persistent storage and then, when you need to remove it, deserialize it and remove that exact event.
This assumes that you want to add and remove events between multiple application launches and that the user does not modify your event by hand (dunno if it's even possible but still).
Also from what I see in the documentation EKEvent has much more properties than just two you listed.
EKEvent Class Reference