Ios 如何检测已更改的事件

Ios 如何检测已更改的事件,ios,ekevent,ekeventkit,ekeventstore,Ios,Ekevent,Ekeventkit,Ekeventstore,我有问题。我需要知道我的EventStore中的事件何时发生更改,因此对于这种情况,我使用EKEventStoreChangedNotification,但此通知返回给我的是userInfo 看起来是这样的: EKEventStoreChangedObjectIDsUserInfoKey = ("x-apple-eventkit:///Event/p429" ); 我不知道如何使用这些数据来访问已更改的对象。请帮助我这将检测更改的事件,并记录日期范围内的事件标题。虽然,我最终没有这样做,因为实

我有问题。我需要知道我的EventStore中的事件何时发生更改,因此对于这种情况,我使用
EKEventStoreChangedNotification
,但此通知返回给我的是
userInfo
看起来是这样的:

EKEventStoreChangedObjectIDsUserInfoKey = ("x-apple-eventkit:///Event/p429" );

我不知道如何使用这些数据来访问已更改的对象。请帮助我

这将检测更改的事件,并记录日期范围内的事件标题。虽然,我最终没有这样做,因为实际上我不知道日期范围。我需要与我正在处理的所有事件进行比较,这意味着我无论如何都需要刷新它们,因为对象ID可能已经更改。这最终会使每个事件都变得不那么有用,现在我只要在发生更改时每隔几秒钟刷新一次,然后忽略细节。我希望苹果能改进这些通知

#pragma mark - Calendar Changed
- (void)calendarChanged:(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);
                *stop = YES;
            }
        }];
    }];
}

AppStore是否会接受这一点
objectID
在本例中似乎是一个“私有api”调用。我只在实验中使用过它,所以我不知道。我想我发现EKEvents会通过猜测它们在内部是NSManagedObject来响应objectID(因此是typecast),但从超类来看,情况似乎并非如此。