iOS EventKit Accessing different types of calendars

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Accessing the array of calendars

To access the array of EKCalendars, we use the calendarsForEntityType method:

Swift

let calendarsArray = eventStore.calendarsForEntityType(EKEntityType.Event) as! [EKCalendar]

Iterating through calendars

Just use a simple for loop:

Swift

for calendar in calendarsArray{
    //...
}

Accessing the calendar title and color

Swift

let calendarColor = UIColor(CGColor: calendar.CGColor)
let calendarTitle = calendar.title

Objective-C

UIColor *calendarColor = [UIColor initWithCGColor: calendar.CGColor];
NSString *calendarTitle = calendar.title;


Got any iOS Question?