EKEventStore.calendars返回不存在的“日历”对象

时间:2012-03-05 09:03:26

标签: iphone objective-c ios

使用

获取IOS5上的所有日历时
EKEventStore *eventStore = [[EKEventStore alloc] init];
NSArray * calendars = [eventStore calendars];

返回了一个名为“calendar”的日历。此日历不存在于用户日历列表中。它持有这个属性:

EKCalendar <0x357700> {title = Calendar; type = Local; allowsModify = YES; color = #882F00;

用户可以在那里存储活动。这些事件显示在IOS日历上。有谁知道这是什么样的日历?似乎是某种默认日历。 BTW:用户日历都是基于CalDAV的,所以这可能就是这个对象的原因。

1 个答案:

答案 0 :(得分:1)

在代码中,您无法完全访问用户在其原生应用中拥有的所有日历。

"Event Kit provides limited access to a user’s calendar information. It is not
suitable for implementing a full-featured calendar application."

如果您想编辑现有活动,则不会有任何问题:

 "You can fetch events based on a date range or a unique identifier,
receive notifications when event records change, and allow users to create
and edit events for any of their calendars. Changes made to events in a
user’s Calendar database with Event Kit are automatically synced with the
appropriate calendar (CalDAV, Exchange, and so on)."

如果您想添加新活动,则只能将其添加到用户选择为默认日历的日历中(在设置应用中)。

    "Creating and Editing Events

    If the event property is nil when you present the view controller,
the user creates a new event in the default calendar and saves it to
the specified event store.

    If the event property is nil when you present the view controller,
the user creates a new event in the default calendar and saves it to
the specified event store."

来自Event Kit Programming Guide的所有引文。