I'm new to iOS programming and I am working on a easy project that lists holidays from a given city and gives users the ability to add those events to the iCal default calendar.
The issue is: how to check if there is already an event with same properties (title and start date for example) in the user's calendar. This could happen if the action button (used to add an event to iCal) is pressed more than once. In such a situation, I don't want two or more identical events being created in iCal.
I have tried to use NSPredicate but I am totally lost on how to get it sorted.
Any help would come be appreciated! Thanks in advance.
Bellow is my event-adding code just to make things clear. In this case a user is adding multiple events from a list (all local holidays for example).
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];
}