我正在我的应用程序中设置提醒。我使用EKEvent
to添加了一个自定义事件iCal
。现在,当我从中检索事件时,iCal
我会得到当天存在的所有事件。有什么方法可以获取/检索仅通过我的应用程序添加的事件,我尝试eventIdentifier
了属性,EKEvent
但它是只读属性。有人可以帮忙吗???
问问题
2094 次
2 回答
2
您可以遍历与特定日期匹配的所有日历事件,但这不是首选方法。每个事件都是使用唯一的 eventIdentifier 属性创建的。当您保存事件时,您可以复制 eventIdentifier,下次您想修改该特定事件时,您可以使用 EKEventStore eventWithIdentifier 方法来加载您的事件。
样本可能如下所示
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];
稍后,如果您想从以前的代码中检索保存的事件,您可以执行以下操作
//self.calendarEventID is a NSString property declared in the .h file and synthesized in .m EKEvent *myEvent = [eventStore eventWithIdentifier:self.calendarEventID];
于 2011-07-11T19:29:32.890 回答
1
克鲁奇:
我为设置 iCal 警报而制作的 AppleScript 也遇到了类似的问题;我希望能够识别和删除我的脚本在下一次传递时发生的事件。
我找不到 iCal 事件的任何类似标签的属性,所以我最终使用了 location 属性,它是一个字符串;我将其设置为“”并进行了搜索。(警告:警报消息包括最后的位置,被括号包围,所以这有点混乱。)
如果您在应用程序中需要 location 属性用于其他目的,您仍然可以添加一些识别字符序列。或者,也许您可以使用其他不需要的属性。
于 2011-03-05T15:58:44.327 回答