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

标签 iphone calendar icalendar eventkit reminders

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

最佳答案

您可以循环遍历与特定日期匹配的所有日历事件,但这不是首选方法。每个事件都是使用唯一的 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/

相关文章:

ios - uitextfield selected 更改状态栏颜色

iphone - 将数据预加载到核心数据中是更好的 csv 还是 sqlite?

iphone - 动画 CATextLayer 字符串属性

angularjs - 谷歌日历的 API OAuth Google 集成访问错误(来源不匹配)

asp.net - webcal URI 方案上的 ics 文件

iphone - UIView 呈现黑屏,修复了吗?

javascript - 如何将日历开始日期布局从星期日更改为星期一?

android - 找不到处理 Intent 的 Activity { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event

python - 如何使用 Python 确定 Google 日历中的当前事件?

.net - .NET中的双向可更新iCal文件