Chapter 16. EventKit

The user’s life isn’t confined to the use of computers and phones, and many people even use technology to manage real-life interactions with other human beings. One capability of Apple devices is calendaring and scheduling, which is usually managed through built-in applications (the Calendar app on iOS and OS X).

However, it can be very useful for third-party applications to be able to access the calendar, either to create new appointments or to view what the user has lined up for the day. This information is exposed via EventKit, the calendar data store API.

In this chapter, you’ll learn how to work with EventKit to access the user’s calendar. The same API applies to both OS X and iOS; in this chapter, the sample code will be written for OS X.

Understanding Events

All of the information that relates to the user’s calendars comes from the EventKit event store. This is the database of the user’s calendars, which themselves contain calendar events. The event store is represented by the EKEventStore class, and you create an instance of this class to begin working with the calendar.

The event store contains multiple calendars, which are EKCalendar objects. Each calendar has information like its name, whether it’s editable, whether it’s a subscribed calendar, and so on.

An “event” is an entry in the user’s calendar, and is represented as an EKEvent object. Events contain several key pieces of information, including:

  • A text label describing what the event is
  • The date and ...

Get Swift Development with Cocoa now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.