Array of calendars

I created NSMutableArray for EKCalendars, which uses my application. The first time I start, I import all calendars from EventStore, but I exclude the Birthdays calendar and the default calendar, leaving only user-created calendars. However, the problem is that there is only a birthday calendar and a default calendar. Here is what I still have ...

for (int i = 0; i < theEventStore.calendars.count; i++) { EKCalendar *c = [theEventStore.calendars objectAtIndex:i]; if (c.type != EKCalendarTypeBirthday && c.type != EKCalendarTypeSubscription) { if (c.type == EKCalendarTypeLocal && [c.title isEqualToString:@"Calendar"]) { NSLog(@"Removed Calendar: %@", c); } else { [self.calendarLst addObject:c]; NSLog(@"Added Calendar: %@", c); } } } 

I'm a little deadlocked. Any help would be appreciated.

+1
source share
1 answer

I added this after the original loop. This ensures that there is something in the array.

 int count = self.calendarLst.count; NSLog(@"Count: %i",count); if (count == 0) { for (int i = 0; i < theEventStore.calendars.count; i++) { EKCalendar *c = [theEventStore.calendars objectAtIndex:i]; if (c.type == EKCalendarTypeLocal && [c.title isEqualToString:@"Calendar"]) { [self.calendarLst addObject:c]; NSLog(@"Added Calendar: %@", c); } } } } 

The problem is not in the loop, it is an empty array.

0
source

All Articles