This article is based on iOS 4 in Action, to be published on June 2011. It is being reproduced here by permission from Manning Publications. Manning publishes MEAP (Manning Early Access Program,) eBooks and pBooks. MEAPs are sold exclusively through Manning.com. All pBook purchases include free PDF, mobi and epub. When mobile formats become available all customers will be contacted and upgraded. Visit Manning.com for more information. [ Use promotional code 'java40beat' and get 40% discount on eBooks and pBooks ]
An Overview of the Event Kit Frameworks
Calendar apps coming with iOS on iPhone and iPad are really convenient for several reasons. They allow users to check out the schedule on the go and consolidate all the information into one Calendar database.
Adding Event Kit frameworks to your project
In order to use the Event Kit frameworks, we first need to add the existing Frameworks EventKit.framework and EventKitUI.framework to the project. Head over to Xcode, right-click on the folder Frameworks on left panel, choose Add>Existing Frameworks…; you should be able to see the whole list of available frameworks under current SDK, as shown in figure 2. Navigate to EventKit.framework and click on button Add. You will see a new framework added to your project. Repeat the same process for the Event Kit UI framework.
- #import <EventKit/EventKit.h>
- #import <EventKitUI/EventKitUI.h>
With the Event Kit frameworks added to the project, you can start to use them for accessing Calendar’s database from the application. First, we will take a look at the Event Kit Classes.
Event Kit Classes
Inside the powerful Event Kit API, there are a handful of classes that are like a lot of useful friends; figure 3 gives you a general idea about the relationships among these important classes.
EKEventStore *store = [[EKEventStore alloc] init];
Please note that this initial method may consume a lot of time, so it’s a good practice to keep that EKEventStore object in your program around for all the data access.
EKEvent is the object representing an event, which includes some import properties listed in table 1.
After the EKEventStore object is initialized, the calendar’s ready for adding or deleting events. You can create an event object and add it to the calendar’s database programmatically. Alternatively, you can use Event Kit UI framework for event view controllers, which is a great choice for user interface. The Event Kit UI framework contains two types of view controllers for manipulating events:
- EKEventViewController—Use the EKEventViewController class if you have an existing event you want to display or allow the user to edit.
- EKEventEditViewController—Use the EKEventEditViewController class if you allow the user to create, edit, or delete events.
The Event Kit framework provides an interface for accessing calendar events on a user’s device. You can use this framework to get existing events and add new events to the user’s calendar. In this article, you learned how to accomplish this task with the Event Kit UI view controllers.
Latest posts by Krishna Srinivasan (see all)
- 5 New Features in HTML5 - November 29, 2013
- How To Set Tomcat JVM Heap Size in Eclipse? - November 28, 2013
- How To Resolve “Resource Is Out Of Sync With The Filesystem” Error in Eclipse? - November 28, 2013