我在我的应用程序中添加提醒事件Eventkit.framework
,但是当我在我的应用程序中显示提醒事件时,它会显示iPhone 中的所有提醒事件,但我只想显示我添加的提醒事件。
这是我使用模态视图控制器添加事件的代码
EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil];
EKEvent * eve = [EKEvent eventWithEventStore:self.eventStore];
addController.eventStore = self.eventStore;
addController.event = eve;
[self presentModalViewController:addController animated:YES];
这是检索提醒事件的代码
self.eventStore = [[EKEventStore alloc] init];
self.eventsList = [[NSMutableArray alloc] initWithArray:0];
self.defaultCalendar = [self.eventStore defaultCalendarForNewEvents];
self.navigationController.delegate = self;
[self.eventsList addObjectsFromArray:[self fetchEventsForToday]];
获取事件方法
- (NSArray *)fetchEventsForToday {
NSDate *startDate = [NSDate date];
NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400];
NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar];
NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate
calendars:calendarArray];
NSArray *events = [self.eventStore eventsMatchingPredicate:predicate];
return events;
}