14.10. Presenting Event Edit View Controllers

Problem

You want to allow your users to edit (insert, delete, and modify) events in the Calendar database from inside your application, using built-in SDK view controllers.

Solution

Instantiate an object of type EKEventEditViewController and present it on a navigation controller using the presentModalViewController:animated: instance method of UINavigationController.

Discussion

An instance of the EKEventEditViewController class allows us to present an event edit view controller to the user. This view controller, depending on how we set it up, can allow the user to either edit an existing event or create a new event. If you want this view controller to edit an event, set the event property of this instance to an event object. If you want the user to be able to insert a new event into the system, set the event property of this instance to nil.

The editViewDelegate property of an instance of EKEventEditViewController is the object that will receive delegate messages from this view controller telling the programmer about the action the user has taken. One of the most important delegate messages your delegate object must handle (a required delegate selector) is the eventEditViewController:didCompleteWithAction: method. This delegate method will be called whenever the user dismisses the event edit view controller in one of the possible ways indicated by the didCompleteWithAction parameter. This parameter can have values such as the following:

EKEventEditViewActionCanceled ...

Get iOS 5 Programming Cookbook 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.