title: Add events to iCal from iPhone App, The event has no calendar set Error?
body: <p>I have one problem while adding multiple events more than 70 events repeatedly again and again to the iCal from our iPhone application. First 20 events add to iCal without any issues. After the balance events not adding to iCal. The error log from the iCal shows the given </p>
  
  <blockquote>
    <p>Error, ["Error Domain=EKErrorDomain Code=1 "The event has no calendar
    set." UserInfo=0xfada510 {NSLocalizedDescription=The event has no
    calendar set.}”].</p>
  </blockquote>
  
  <p>Below i have attached my code. Please help me to solve this problem.</p>
  
  <pre><code>int count = [eventsArray Count];
  for(int i=0;i&lt;count;i++)
  {
      EKEventStore *eventStore = [[EKEventStore alloc] init]; 
      EKEvent *events = [EKEvent eventWithEventStore:eventStore];
  
      events.title = @"Apple";
      events.notes = @"Apple iPhone";  
      events.location = @"US";
      events.startDate = today;
      events.endDate   = tomorrow;    
      events.availability = EKEventAvailabilityFree;
      [events setCalendar:[eventStore defaultCalendarForNewEvents]];
      NSError *error;
      [eventStore saveEvent:events span:EKSpanThisEvent error:&amp;error];
      NSLog(@"Error From iCal : %@", [error description]);
  
      NSString *eventId = [[NSString alloc] initWithFormat:@"%@", events.eventIdentifier];
      NSLog(@"EventID : %@", eventId);
  }
  </code></pre>
  
  <p>The count maybe more than 70(sometimes it will be only 20-30 events).
  This code is in For loop. This code will execute nearly more than 70 times. The iCal error log displays the error "This event has no calendar set" and the eventid returns Null. How to overcome this problem. Please help me to solve this. Thanks in advance.</p>