将自定义值存储在EKEvent中(iPhone日历)

问题描述:

我的应用程序与设备日历集成.将新项目添加到我的应用程序后,我们将为此项目创建一个日历条目.如果该项目被修改,我们需要更新日历项目.

My app integrates with the device calendar. When a new item is added to my app we create a calendar entry for this item. If the item is edited we need to update the calendar item.

我现在要做的是将GUID放入EKEvent.Notes,但显然这对用户是可见的,因此我们添加了文本请勿删除".然后,我们在日历中搜索包含GUID的Notes,以找到相关的项目.

What I do now is put a GUID in the EKEvent.Notes but obviously this is visible to the user so we add a text "do not delete". We then search the calendar for Notes containing the GUID to find the related item.

最理想的情况是EKEvent具有Tag属性,或者某种类型的隐藏字段可以采用字符串值.然后,我们可以将相关的唯一ID存储在此字段中,而不会使用户的注释字段混乱.

What would be ideal is if the EKEvent had a Tag property or if there was some type of hidden field that could take a string value. We could then store our related unique ID in this field and not clutter the user's notes field.

关于如何处理此问题的任何建议?

Any suggestions on how to handle this?

谢谢.

您到底想做什么? "eventIdentifier"属性用于唯一标识EKEvent实例.使用EKEventStore,您可以使用此标识符查找现有的EKEvent.将该值设为只读也就不足为奇了.

What is it exactly what you want to do? The 'eventIdentifier' property is meant to uniquely identify an EKEvent instance. Using the EKEventStore you can look up an existing EKEvent using this identifier. It is no surprise this value is read-only.

我可以想象您要区分日历中已经存在的事件和您的应用创建的事件.我的解决方案是对您添加到日历中的事件进行本地注册.例如,您可以将其存储在本地SQLite数据库中.您可以使用"eventIdentifier"值引用iPhone日历中的事件.

I can imagine that you want to differentiate between events that were already in the calendar and events that your app created. My solution would be to keep a local registration of what events you added to the calendar. You could for example store this in a local SQLite database. You can refer to events in the iPhone calendar using the 'eventIdentifier' values.