O'Reilly logo

Programming iOS 8 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Calendar

The user’s calendar information, which the user sees through the Calendar app, is effectively a database of calendar events. The calendar database also includes reminders, which the user sees through the Reminders app. This database can be accessed directly through the Event Kit framework. You’ll need to import EventKit.

Warning

Type names in the Event Kit framework have not been abbreviated for Swift. For example the EKEntityType names are EKEntityTypeEvent and EKEntityTypeReminder, not .Event and .Reminder.

A user interface for interacting with the calendar is also provided, through the Event Kit UI framework. You’ll need to import EventKitUI.

Calendar Database

The calendar database is accessed as an instance of the EKEventStore class. This instance is expensive to obtain but lightweight to maintain, so your usual strategy will be to instantiate and retain one EKEventStore instance. Fortunately, a calendar database instance, unlike an address book database instance (see Chapter 18), cannot be faulty; thus there is no harm whatever in initializing a property as an EKEventStore instance and keeping that reference for the rest of the app’s lifetime:

var database = EKEventStore()

In the examples in this chapter, my EKEventStore instance is called self.database throughout.

Calendar Database Authorization

Calendar database authorization is parallel to the authorization verification that I described at the start of Chapter 18. The chief difference is that, although there ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required