简体   繁体   English

如何在EKEvent中识别EKAlarm

[英]How to identify an EKAlarm in an EKEvent

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? 我想知道是否为EKEvent设置了警报,当我想删除它时如何识别它?

The only accessible properties of the EKAlarm are absoluteDate and relativeOffset. EKAlarm的唯一可访问属性是absoluteDate和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. 如果我设置的警报与其他用户生成的警报具有相同的relativeOffset或absoluteDate,我觉得这会引起问题。

Any suggestions? 有什么建议么?

如果有两个警报具有相同的absoluteDate,则删除一个或另一个警报似乎是完全可以接受的,它们本质上是重复的。

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中看到的内容来看,除了列出的两个属性外,EKEvent还具有更多的属性。

EKEvent Class Reference EKEvent类参考

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

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