I'm new to iOS programming, and I'm working on a simple project that lists holidays from a given city and gives users the ability to add these events to the iCal default calendar.
The problem is how to check if the userβs calendar already has the same property (name and start date). This can happen if the action button (used to add an event to iCal) is pressed more than once. In this situation, I do not want to create two or more identical events in iCal.
I tried using NSPredicate, but I completely lost the sorting method.
Any help would be appreciated! Thanks in advance.
Bellow is my event adding code to make things clear. In this case, the user adds several events from the list (for example, all local holidays).
for (int i = 0; i<[allHolidayNames count]; ++i) { // ------ EVENT MANIPULATION ------ EKEventStore *eventStore = [[EKEventStore alloc] init]; EKEvent *addEvent = [EKEvent eventWithEventStore:eventStore]; addEvent.title = [allHolidayNames objectAtIndex:i]; addEvent.startDate = [allHolidayDates objectAtIndex:i]; addEvent.allDay = YES; [addEvent setCalendar:[eventStore defaultCalendarForNewEvents]]; [eventStore saveEvent:addEvent span:EKSpanThisEvent commit:YES error:nil]; }
source share