EKEventStore
An object that accesses a person’s calendar events and reminders and supports the scheduling of new events.
Declaration
class EKEventStoreMentioned in
Overview
The EKEventStore class is an app’s point of contact for accessing calendar and reminder data.
After initializing the event store, you must request access to events or reminders before attempting to fetch or create data. To request access to reminders, call requestFullAccessToReminders(completion:). To request access to events, call requestWriteOnlyAccessToEvents(completion:) or requestFullAccessToEvents(completion:).
A typical workflow for using an event store is:
Create a predicate, or a search query for events, with predicateForEvents(withStart:end:calendars:).
Fetch and process events that match the predicate with the events(matching:) and enumerateEvents(matching:using:) methods.
Save and delete events from the event store with the save(_:span:commit:) and remove(_:span:commit:) methods.
Use similar methods to access and manipulate reminders.
After receiving an object from an event store, don’t use that object with a different event store. This restriction applies to EKObject subclasses such as EKEvent, EKReminder, EKCalendar, and EKSource, as well as predicates that the event store creates. For example, don’t fetch an event from one event store, modify the event, and then pass it to save(_:span:) in a different store.
Topics
Creating event stores
Requesting access to events and reminders
requestWriteOnlyAccessToEvents(completion:)requestFullAccessToEvents(completion:)requestFullAccessToReminders(completion:)authorizationStatus(for:)EKAuthorizationStatusEKEventStoreRequestAccessCompletionHandlerNSCalendarsFullAccessUsageDescriptionNSCalendarsWriteOnlyAccessUsageDescriptionNSRemindersFullAccessUsageDescription
Accessing account sources
Saving and restoring state
Accessing calendars
defaultCalendarForNewEventsdefaultCalendarForNewReminders()calendars(for:)calendar(withIdentifier:)saveCalendar(_:commit:)removeCalendar(_:commit:)calendars
Accessing calendar events
event(withIdentifier:)calendarItem(withIdentifier:)calendarItems(withExternalIdentifier:)remove(_:span:)remove(_:span:commit:)remove(_:commit:)save(_:span:)save(_:span:commit:)save(_:commit:)
Searching calendars
enumerateEvents(matching:using:)events(matching:)fetchReminders(matching:completion:)cancelFetchRequest(_:)predicateForEvents(withStart:end:calendars:)predicateForReminders(in:)predicateForCompletedReminders(withCompletionDateStarting:ending:calendars:)predicateForIncompleteReminders(withDueDateStarting:ending:calendars:)EKEventSearchCallback