Cover by Vandad Nahavandipoor

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required