iOSでは、EKEventクラスにイベント識別子に関する2つのプロパティeventIdentifierとuuidプロパティがあります。 Mac上で同じ同期イベントをMacで見た場合、CalEventはuidプロパティを持ちますが、これらは私のテストでは一致しません。イベントを正しく識別する方法
誰かが両側のイベントを正しく識別する方法を知っていますか?
iOSでは、EKEventクラスにイベント識別子に関する2つのプロパティeventIdentifierとuuidプロパティがあります。 Mac上で同じ同期イベントをMacで見た場合、CalEventはuidプロパティを持ちますが、これらは私のテストでは一致しません。イベントを正しく識別する方法
誰かが両側のイベントを正しく識別する方法を知っていますか?
iOS 6を使用している場合は、calendarItemExternalIdentifierを試してください。
この識別子を使用すると、複数のデバイス間で同じイベントまたはリマインダーにアクセスできます。
この問題は、コアデータ、iCloudとカレンダーを使用して発生しました。 eventIdentifierをキャプチャして1つのデバイスのコアデータに保存しましたが、カレンダーでeventIdentifierが変更された他のデバイスをチェックしたときにそのデータを保存しました。 iOS Reference
キャプチャイベントの保存calendarItemExternalIdentifier:
- (void)eventEditViewController:(EKEventEditViewController *)controller
didCompleteWithAction:(EKEventEditViewAction)action {
NSError *error = nil;
EKEvent *thisEvent = controller.event;
switch (action) {
case EKEventEditViewActionCanceled:
// Edit action canceled, do nothing.
break;
case EKEventEditViewActionSaved:
{[self.selectedClientSession setEventIdentifier:[thisEvent calendarItemExternalIdentifier]];
.......
アプリにイベントを表示し、クエリはイベントが1である場合を
ではなく、EventIdentifierののcalendarItemExternalIdentifierをキャプチャすることによってそれを解決しました「セッション」イベント:
// Get the event e.g. from a tableview listing of events today
calendarEvent = (EKEvent*)[eventsList2 objectAtIndex:indexPath.row];
// Is this one of our session events? Build a predicate to query our clientSession objects by comparing the identifier we captured with the Event calendarItemExternalIdentifier
self.sessionPredicate = [NSPredicate predicateWithFormat:@" eventIdentifier = %@ ",[calendarEvent calendarItemExternalIdentifier]
// Get the results
[self setupFetchedResultsController];
//Check that calendarItemExternalIdentifier has been recorded in our session database
NSArray *sessionSet = [self.fetchedResultsController fetchedObjects];
//If no results then this is not a client session
if (sessionSet.count == 0){
// Just a regular event to display
} else{
//It is a client session - display and allow to do interesting stuff
}
EKEvent
プロパティeventIdentifier
の後半には、プロパティuid
が含まれているように見えます。 eventIdentifier
の最初の識別子(コロンの前)が何であるか分かりません。それはカレンダーに関連しているようですが、私はその識別子を認識しません。
cあなたは 'calendarItemExternalIdentifier'で' eventWithIdentifier: 'を使用しますか? –