October 2013
Intermediate to advanced
1053 pages
28h 7m
English
You want to get notified in your application when the user changes the contents of the Calendar database.
Register for the EKEventStoreChangedNotification
notification:
-(void)eventsChanged:(NSNotification*)paramNotification{NSMutableArray*invalidatedEvents=[[NSMutableArrayalloc]init];NSLog(@"Refreshing array of events...");for(EKEvent*eventinself.eventsForOneYear){if([eventrefresh]==NO){[invalidatedEventsaddObject:event];}}if([invalidatedEventscount]>0){[self.eventsForOneYearremoveObjectsInArray:invalidatedEvents];}}-(void)handleNotificationsInStore:(EKEventStore*)paramStore{EKSource*icloudSource=[selfsourceInEventStore:paramStoresourceType:EKSourceTypeCalDAVsourceTitle:@"iCloud"];if(icloudSource==nil){NSLog(@"You have not configured iCloud for your device.");return;}EKCalendar*calendar=[selfcalendarWithTitle:@"Calendar"type:EKCalendarTypeCalDAVinSource:icloudSourceforEventType:EKEntityTypeEvent];if(calendar==nil){NSLog(@"Could not find the calendar we were looking for.");return;}NSTimeIntervalNSOneYear=1*365*24*60*60;NSDate*startDate=[NSDatedate];NSDate*endDate=[startDatedateByAddingTimeInterval:NSOneYear];NSPredicate*predicate=[paramStorepredicateForEventsWithStartDate:startDateendDate:endDatecalendars:@[calendar]];NSArray*events=[paramStoreeventsMatchingPredicate:predicate];self.eventsForOneYear=[[NSMutableArrayalloc ...
Read now
Unlock full access