Ios 如何检测事件存储更改以及更改是什么?来自EKEventStoreChangedNotification

Ios 如何检测事件存储更改以及更改是什么?来自EKEventStoreChangedNotification,ios,objective-c,ekeventstore,ekeventkit,Ios,Objective C,Ekeventstore,Ekeventkit,如何知道EKEvent是否已添加或删除?这样我就可以安排活动通知。否则,对于已删除事件,它也将安排通知。有什么帮助吗 -(void)storeChanged:(NSNotification*)notification{ EKEventStore *ekEventStore = notification.object; NSDate *now = [NSDate date]; NSDateComponents *offsetComponents = [NSDateCo

如何知道EKEvent是否已添加或删除?这样我就可以安排活动通知。否则,对于已删除事件,它也将安排通知。有什么帮助吗

 -(void)storeChanged:(NSNotification*)notification{

    EKEventStore *ekEventStore = notification.object;

    NSDate *now = [NSDate date];
    NSDateComponents *offsetComponents = [NSDateComponents new];
    [offsetComponents setDay:0];
    [offsetComponents setMonth:4];
    [offsetComponents setYear:0];
    NSDate *endDate = [[NSCalendar currentCalendar] dateByAddingComponents:offsetComponents toDate:now options:0];

    NSArray *ekEventStoreChangedObjectIDArray = [notification.userInfo objectForKey:@"EKEventStoreChangedObjectIDsUserInfoKey"];
    NSPredicate *predicate = [ekEventStore    predicateForEventsWithStartDate:now
                                                                      endDate:endDate
                                                                    calendars:nil];
    // Loop through all events in range
    [ekEventStore enumerateEventsMatchingPredicate:predicate usingBlock:^(EKEvent *ekEvent, BOOL *stop) {
        // Check this event against each ekObjectID in notification
        [ekEventStoreChangedObjectIDArray enumerateObjectsUsingBlock:^(NSString *ekEventStoreChangedObjectID, NSUInteger idx, BOOL *stop) {
            NSObject *ekObjectID = [(NSManagedObject *)ekEvent objectID];
            if ([ekEventStoreChangedObjectID isEqual:ekObjectID]) {
                // Log the event we found and stop (each event should only exist once in store)
                NSLog(@"calendarChanged(): Event Changed: title:%@", ekEvent.title);

                NSLog(@"%@",ekEvent);

                NSInteger total = [[[UIApplication sharedApplication] scheduledLocalNotifications]count];
                if (total == 64) {
                    [self cancelLastNotification];
                }

                NSArray *newArray = [[NSArray alloc]initWithObjects:ekEvent, nil];
                [self scheduleNotificationForCalendarEvents:NO andEvents:newArray];

                *stop = YES;
            }
        }];
    }];

}

如果使用
refresh
属性,则删除该属性后将返回false,如果仍然可以使用该属性,则返回true

如果使用
refresh
属性,则删除该属性后将返回false,如果仍然可以使用该属性,则返回true