O'Reilly logo

iOS 6 Programming Cookbook by Vandad Nahavandipoor

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

16.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 ...

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