Alex Rivera | Logout

How can my app get a list of calendars on user's iPhone

Asked 2011-01-08T19:10:43.627
11

I'm writing an iPhone app that will use the EventKit framework to create new events in the user's Calendar. That part works pretty well (except for the wonky way it handles the timezone -- but that's another issue). What I can't figure out is how to get a list of the user's calendars so that they can choose which calendar to add the event to. I know that its an EKCalendar object but the docs don't show any way to get the whole collection.

Thanks in advance,

Mark

Edit
Report

1 Answer

21

Searching through the documentation reveals an EKEventStore class that has a calendars property.

My guess is that you'd do something like:

EKEventStore * eventStore = [[EKEventStore alloc] init];
NSArray * calendars = [eventStore calendars];

EDIT: As of iOS 6, you need to specify whether you want to retrieve calendars of reminders or calendars of events:

EKEventStore * eventStore = [[EKEventStore alloc] init];
EKEntityType type = // EKEntityTypeReminder or EKEntityTypeEvent
NSArray * calendars = [eventStore calendarsForEntityType:type];    
answered 2011-01-08T19:17:40.843

Your Answer