iCloud同步不通过无处不在的容器发送数据

我一直在我的应用程序中使用iCloud一段时间,最近有一个问题,设备拒绝互相交谈。 或者至less这是我想到的,直到我开始logging合并发生的方法。 我的persistentStoreCoordinator按照我之前的一个问题进行了设置 。

问题是以下。 当设置我的managedObjectContext ,我添加一个观察者来查看NSPersistentStoreDidImportUbiquitousContentChangesNotification通知如下所示:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mergeChangesFrom_iCloud:) name:NSPersistentStoreDidImportUbiquitousContentChangesNotification object:coordinator]; 

coordinator被设置为NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]

我的iCloud方法如下:

 - (void)mergeiCloudChanges:(NSNotification *)note forContext:(NSManagedObjectContext *)moc { NSLog(@"insert %@", [[note userInfo] valueForKey:@"inserted"]); NSLog(@"delete %@", [[note userInfo] valueForKey:@"deleted"]); NSLog(@"update %@", [[note userInfo] valueForKey:@"updated"]); [moc mergeChangesFromContextDidSaveNotification:note]; NSNotification *refreshNotification = [NSNotification notificationWithName:@"RefreshAllViews" object:self userInfo:[note userInfo]]; [[NSNotificationCenter defaultCenter] postNotification:refreshNotification]; } - (void)mergeChangesFrom_iCloud:(NSNotification *)notification { NSLog(@"merging changes"); NSManagedObjectContext *moc = [self managedObjectContext]; [moc performBlock:^{ [self mergeiCloudChanges:notification forContext:moc]; }]; } 

所以现在我们有实际的问题

起初,同步完美无瑕。 来自一个设备的数据被改变了,然后这个改变出现在另一个设备上。 但是现在什么都没有 好奇的部分是你在mergeiCloudChanges:forContext:看到的那些日志mergeiCloudChanges:forContext: 合并实际上发生。 我看到这引发了。 但是insertdeleteupdate合并注释的部分总是没有内容。 所以合并发生,但没有数据。 对于我的生活,我不知道为什么这是或如何让它再次正确同步。 任何帮助将不胜感激。

注意:我也使用NSUbiquitousKeyValueStoreDidChangeExternallyNotification通知为我的NSUbiquitousKeyValueStore (我用来同步NSUserDefault键值),这些通知转移和更新,没有任何打嗝,这更多的困扰我为什么persistentStoreCoordinator通知空白。

我真的希望有人见过/经历过这个,因为经过两个星期,我可以想尽一切办法find并解决这个问题,我觉得我现在处于停滞状态。

我find了这个。 基本上,事务日志似乎已损坏或错位。 我重新devise了一个resycn设备的方法,并将立即发布结果在我以前的问题