ios – EKEvent的eventIdentifier和calendarItemExternalIdentifier之间的区别

阅读Apple的文档,我仍然对 EKCalenderItem’s calendarItemExternalIdentifierEKEvent’s eventIdentifier间的差异感到困惑,我们应该使用哪一个来识别不同设备上的日历事件.特别:

EKCalendarItem calendarItemExternalIdentifier
The calendar item’s external identifier as provided by the calendar server. (read-only)

EKEvent eventIdentifier: A unique identifier for the event. (read-only)

EKCalendarItem calendarItemExternalIdentifier是在iOS6中添加的,我原以为这是我需要保存的标识符,以便稍后在EKEventStore eventWithIdenfier中调用:因为它声称:

This identifier allows you to access the same event or reminder across
multiple devices.

但是在我自己的测试中,似乎当我创建并保存新的EKEvent时,我从EKEvent对象获得的eventIdenifier是唯一且有用的,而我得到的calendarItemExternalIdentifier似乎不适用于EKEventStore eventWithIdenfier:

如果有人有确凿的答案,我很想知道.

解决方法

calendarItemExternalIdentifier是事件的 RFC 5545全局唯一标识符.它不是特定于EKEventStore,实际上它代表跨设备的事件(以及非iOS客户端).如果您要从收件箱中打开.ics附件,则此值将显示在邀请的UID字段中.

也就是说,您无法直接根据此标识符查找EKEventStore事件.相反,您需要在事件存储上执行谓词搜索,并检查每个事件的calendarItemExternalIdentifier.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...