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

mpemburn picture mpemburn · Jan 8, 2011 · Viewed 7k times · Source

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

Answer

Dave DeLong picture Dave DeLong · Jan 8, 2011

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];