有什么方法可以添加在 iCal 中添加的标识符或标记自定义事件吗?
我正在我的应用程序中设置提醒。我已使用 EKEvent
将自定义事件添加到 iCal
。现在,当我从 iCal
检索事件时,我会获取当天发生的所有事件。有没有办法仅获取/检索通过我的应用程序添加的事件,我尝试了 EKEvent
的 eventIdentifier
属性,但它是只读属性。 有人可以帮忙吗???
I am setting a reminder in my app. I have added a custom event using EKEvent
to iCal
. Now when I retrieve events from iCal
I get all the events present on that day. Is there any way to get/retrieve events added through my app only, I tried eventIdentifier
property of EKEvent
but it is a readonly property.
Can anybody help???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以循环遍历与特定日期匹配的所有日历事件,但这不是首选方法。每个事件都是使用唯一的 eventIdentifier 属性创建的。当您保存事件时,您可以复制 eventIdentifier,下次您想要修改该特定事件时,您可以使用 EKEventStore eventWithIdentifier 方法来加载您的事件。
示例可能如下所示
稍后,如果您想从之前的代码中检索保存的事件,您可以执行以下操作
You could loop through all of the calendar events that match a specific date but that is not the preferred method. Each event is created with a unique eventIdentifier property. When you save the event you can copy the eventIdentifier and next time you want to modify that specific event you can use the EKEventStore eventWithIdentifier Method to load your Event.
A sample might look like this
Later if you want to retrieve the saved event from the previous code you could do the following
Kludge:
我为设置 iCal 闹钟而制作的 AppleScript 也遇到了类似的问题;我希望能够识别并删除我的脚本在下一次传递时发生的事件。
我找不到 iCal 事件的任何类似标记的属性,因此我最终使用了 location 属性,它是一个字符串;我将其设置为“”并进行搜索。 (警告:警报消息包含末尾的位置,由括号包围,因此这会使事情变得有点模糊。)
如果您需要位置属性用于应用程序中的其他目的,您仍然可以添加一些识别字符序列。或者也许您可以使用您不需要的其他属性。
Kludge:
I had a similar problem with an AppleScript I made for setting iCal alarms; I wanted to be able to identify and delete the events my script had made on the next pass.
I couldn't find any tag-like properties for iCal events, so I ended up using the location property, which is a string; I set it to " " and searched for that. (Caveat: The alarm message includes the location at the end, surrounded by parens, so this glops things up a bit.)
If you need the location property for other purposes in your app, you still might be able to add some identifying character sequence. Or maybe you can use some other property you don't otherwise need.