Chapter 32. Calendar

The user’s calendar information, which the user sees through the Calendar app, is effectively a database. This database can be accessed directly through the Event Kit framework. You’ll link to EventKit.framework and import <EventKit/EventKit.h>.

A user interface for interacting with the calendar is also provided, through the Event Kit UI framework. This interface basically replicates part of the Calendar app. You’ll link to EventKitUI.framework and import <EventKitUI/EventKitUI.h>.

Warning

When you use Event Kit, you’re messing with the user’s calendars. You can very easily, accidentally or on purpose, delete all the user’s calendars, and with them, their events (see Library Access Inconsistencies). The consequences can be very dire, and they are even worse if those calendars are shared in some way. For example, if the user synchronizes calendar data through iCloud, those deletions can instantly propagate through the cloud to the user’s other devices and computers. And there’s no Undo. Be careful out there. Even if you’re just experimenting on your own device, keep good backups. (As usual, I speak from experience.)

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, in an app where you’ll be working with the user’s calendar database, will be to instantiate EKEventStore (by calling [EkEventStore new]) early in the life of the app or ...

Get Programming iOS 5, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.