14.6. Retrieving the Attendees of an Event

Problem

You want to retrieve the list of attendees for a specific event.

Solution

Use the attendees property of an instance of EKEvent. This property is of type NSArray and includes objects of type EKParticipant.

The example code that follows will retrieve all the events that happen today (whatever the day may be) and print out useful event information, including the attendees of that event, to the console window:

- (EKCalendar *) calDAVCalendarWithTitleContaining :(NSString *)paramDescription{ EKCalendar *result = nil; EKEventStore *eventStore = [[EKEventStore alloc] init]; for (EKCalendar *thisCalendar in eventStore.calendars){ if (thisCalendar.type == EKCalendarTypeCalDAV){ if ([thisCalendar.title rangeOfString:paramDescription].location != NSNotFound){ return thisCalendar; } } } return result; } - (void) enumerateTodayEvents{ /* Find a calendar to base our search on */ EKCalendar *targetCalendar = [self calDAVCalendarWithTitleContaining:@"vandad.np@gmail.com"]; /* If we could not find a CalDAV calendar that we were looking for, then we will abort the operation */ if (targetCalendar == nil){ NSLog(@"No CalDAV calendars were found."); return; } /* We have to pass an array of calendars to the event store to search */ NSArray *targetCalendars = [[NSArray alloc] initWithObjects:targetCalendar, nil]; /* Instantiate the event store */ EKEventStore *eventStore = [[EKEventStore alloc] init]; /* Construct the starting date for today */ NSDate *startDate ...

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.