有什么方法可以添加在 iCal 中添加的标识符或标记自定义事件吗?

发布于 2024-10-17 18:02:30 字数 225 浏览 7 评论 0原文

我正在我的应用程序中设置提醒。我已使用 EKEvent 将自定义事件添加到 iCal。现在,当我从 iCal 检索事件时,我会获取当天发生的所有事件。有没有办法仅获取/检索通过我的应用程序添加的事件,我尝试了 EKEventeventIdentifier 属性,但它是只读属性。 有人可以帮忙吗???

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鲜血染红嫁衣 2024-10-24 18:02:30

您可以循环遍历与特定日期匹配的所有日历事件,但这不是首选方法。每个事件都是使用唯一的 eventIdentifier 属性创建的。当您保存事件时,您可以复制 eventIdentifier,下次您想要修改该特定事件时,您可以使用 EKEventStore eventWithIdentifier 方法来加载您的事件。

示例可能如下所示

 EKEventStore *eventStore = [[EKEventStore alloc] init];
   NSError *错误;
   EKEvent *event = [EKEvent eventWithEventStore:eventStore];
   //修改您想要的所有事件属性然后保存
   [eventStore saveEvent:事件跨度:EKSpanThisEvent 错误:&err];
   self.calendarEventID = event.eventIdentifier; 
   [eventStore发布];

稍后,如果您想从之前的代码中检索保存的事件,您可以执行以下操作

 //self.calendarEventID是.h文件中声明并在.m中合成的NSString属性
   EKEvent *myEvent = [eventStore eventWithIdentifier:self.calendarEventID];

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

   EKEventStore *eventStore = [[EKEventStore alloc] init];
   NSError *err;
   EKEvent *event  = [EKEvent eventWithEventStore:eventStore];
   //modify all the event properties you would like then save
   [eventStore saveEvent:event span:EKSpanThisEvent error:&err];
   self.calendarEventID = event.eventIdentifier; 
   [eventStore release];

Later if you want to retrieve the saved event from the previous code you could do the following

   //self.calendarEventID is a NSString property declared in the .h file and synthesized in .m
   EKEvent *myEvent = [eventStore eventWithIdentifier:self.calendarEventID];
睫毛溺水了 2024-10-24 18:02:30

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文