February 2012
Intermediate to advanced
872 pages
22h 43m
English
You want to get notified in your application when the user changes the contents of the Calendar database.
Register for the EKEventStoreChangedNotification
notification:
- (EKCalendar *) calDAVCalendarWithTitleContaining:(NSString *)paramDescription inEventStore:(EKEventStore *)paramEventStore{ EKCalendar *result = nil; for (EKCalendar *thisCalendar in paramEventStore.calendars){ if (thisCalendar.type == EKCalendarTypeCalDAV){ if ([thisCalendar.title rangeOfString:paramDescription].location != NSNotFound){ return thisCalendar; } } } return result; } - (void) eventsChanged:(NSNotification *)paramNotification{ NSMutableArray *invalidatedEvents = [[NSMutableArray alloc] init]; NSLog(@"Refreshing array of events..."); for (EKEvent *event in self.eventsForOneYear){ if ([event refresh] == NO){ [invalidatedEvents addObject:event]; } } if ([invalidatedEvents count] > 0){ [self.eventsForOneYear removeObjectsInArray:invalidatedEvents]; } } - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.eventStore = [[EKEventStore alloc] init]; EKCalendar *calendar = [self calDAVCalendarWithTitleContaining:@"vandad.np@gmail.com" inEventStore:self.eventStore]; NSTimeInterval NSOneYear = 1 * 365 * 24 * 60 * 60; NSDate *startDate = [NSDate date]; NSDate *endDate = [startDate dateByAddingTimeInterval:NSOneYear]; NSArray *calendars = [[NSArray alloc] initWithObjects:calendar, nil]; NSPredicate ...Read now
Unlock full access