我正在我的应用程序中设置提醒。我已使用 EKEvent
将自定义事件添加到 iCal
。现在,当我从 iCal
检索事件时,我会获取当天发生的所有事件。有没有办法仅获取/检索通过我的应用程序添加的事件,我尝试了 EKEvent
的 eventIdentifier
属性,但它是只读属性。
有人可以帮忙吗???
最佳答案
您可以循环遍历与特定日期匹配的所有日历事件,但这不是首选方法。每个事件都是使用唯一的 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];
关于iphone - 有什么方法可以添加在 iCal 中添加的标识符或标记自定义事件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5038450/