Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将id添加到提醒目标C中的事件_Iphone_Objective C_Xcode_Eventkit - Fatal编程技术网

Iphone 将id添加到提醒目标C中的事件

Iphone 将id添加到提醒目标C中的事件,iphone,objective-c,xcode,eventkit,Iphone,Objective C,Xcode,Eventkit,我在应用程序中使用Eventkit.framework添加提醒事件,但当我在应用程序中显示提醒事件时,它会显示iPhone中的所有提醒事件,但我只想显示我添加的提醒事件 下面是我使用模态视图控制器添加事件的代码 EKEventEditViewController *addController = [[EKEventEditViewController alloc] initWithNibName:nil bundle:nil]; EKEvent * eve = [EKEvent eventWit

我在应用程序中使用
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;
}

每个事件都有eventIdentifier属性,这是每个事件的唯一标识字符串。当应用程序添加事件时,它可以将事件标识符存储在应用程序数据中,然后在每次启动时加载该列表。通过确保
[self.eventStore eventWithIdentifier:identifier]返回有效的事件。当您想显示应用程序添加的事件列表时,您只需获取与您保存的标识符匹配的事件即可。由于标识符将永远不会被重用,因此此系统不会受到在应用程序之外添加和删除事件的用户的影响