Class

EKEventStore

An object that accesses the user’s calendar and reminder events and supports the scheduling of new events.

Declaration

class EKEventStore : NSObject

Overview

The EKEventStore class is an application’s point of contact for accessing calendar and reminder data.

In iOS, you must request access to an entity type after the event store is initialized with requestAccess(to:completion:) for data to return.

In macOS, use initWithAccessToEntityTypes: instead of the default init method. Acceptable entity types are event for events and reminder for reminders.

Create a predicate, or a search query for events, with the predicateForEvents(withStart:end:calendars:) method.

Fetch and process events that match a given 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. Reminders are not available in Event Kit before iOS 6.

Topics

Accessing the Event Store

enum EKAuthorizationStatus

The current authorization status for a specific entity type.

typealias EKEventStoreRequestAccessCompletionHandler

The signature for a block object used for operating on events with the requestAccess(to:completion:) method.

typealias EKEventSearchCallback

The signature for a block object used for operating on events with the enumerateEvents(matching:using:) method.

func requestAccess(to: EKEntityType, completion: EKEventStoreRequestAccessCompletionHandler)

Prompts the user to grant or deny access to event or reminder data.

class func authorizationStatus(for: EKEntityType) -> EKAuthorizationStatus

Returns the authorization status for the given entity type.

var eventStoreIdentifier: String

The unique identifier for the event store.

Saving and Restoring State

func commit()

Commits all unsaved changes to the event store.

func reset()

Returns the event store to its saved state.

func refreshSourcesIfNecessary()

Pulls new data from remote sources if necessary.

Instance Methods

func calendarItem(withIdentifier: String) -> EKCalendarItem?

Returns either the event’s first occurrence or the reminder with the specified identifier.

func calendarItems(withExternalIdentifier: String) -> [EKCalendarItem]

Returns either the event’s first occurrences or the reminders with the specified external identifier.

func calendar(withIdentifier: String) -> EKCalendar?

Returns the calendar with the specified identifier.

func calendars(for: EKEntityType) -> [EKCalendar]

Returns an array of calendars that support a given entity type, such as reminders or events.

func cancelFetchRequest(Any)

Cancels the request to fetch reminders.

func defaultCalendarForNewReminders() -> EKCalendar?

The calendar that events are added to by default, as specified by user settings.

func enumerateEvents(matching: NSPredicate, using: EKEventSearchCallback)

Finds all events that match a given predicate and calls a given callback for each event found.

func event(withIdentifier: String) -> EKEvent?

Returns the first occurrence of an event with a given identifier.

func events(matching: NSPredicate) -> [EKEvent]

Returns all events that match a given predicate.

func predicateForEvents(withStart: Date, end: Date, calendars: [EKCalendar]?) -> NSPredicate

Creates and returns a predicate for finding events in the event store that fall within a given date range.

func predicateForReminders(in: [EKCalendar]?) -> NSPredicate

Fetches all reminders in a set of calendars.

func removeCalendar(EKCalendar, commit: Bool)

Removes a calendar from the event store by either batching or committing the changes.

func remove(EKEvent, span: EKSpan)

Removes an event from the event store.

func remove(EKEvent, span: EKSpan, commit: Bool)

Removes an event or recurring events from the event store by either batching or committing the changes.

func remove(EKReminder, commit: Bool)

Removes a reminder from the event store by either committing or batching the changes.

func saveCalendar(EKCalendar, commit: Bool)

Saves a calendar to the event store by either committing or batching the changes.

func save(EKEvent, span: EKSpan)

Saves changes to an event permanently.

func save(EKEvent, span: EKSpan, commit: Bool)

Saves an event or recurring events to the event store by either batching or committing the changes.

func save(EKReminder, commit: Bool)

Saves changes to a reminder by either committing or batching the changes.

func source(withIdentifier: String) -> EKSource?

Returns a source with the specified identifier.

Instance Properties

var defaultCalendarForNewEvents: EKCalendar?

The calendar that events are added to by default, as specified by user settings.

var sources: [EKSource]

Returns an unordered array of source objects.

var calendars: [EKCalendar]

The calendars associated with the event store, as an array of EKCalendar objects.

Deprecated

Relationships

Inherits From

Conforms To

See Also

First Steps

Accessing the Event Store

Request access to a user's calendar data through the event store.