繁体   English   中英

iCloud同步未通过普遍存在的容器发送数据

[英]iCloud sync not sending data through ubiquity container

我已经在我的应用程序中使用iCloud已有一段时间了,最​​近又遇到了设备拒绝互相交谈的问题。 至少在开始记录合并发生的方法之前,这就是我的想法。 我的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:看到的那些日志中。 合并实际上发生。 我看到这触发了。 但是合并注释的insertdeleteupdate部分总是没有内容。 因此发生合并,但没有数据。 对于我的一生,我无法弄清楚这是为什么,或者如何使其重新正确同步。 任何帮助将不胜感激。

注:我也用NSUbiquitousKeyValueStoreDidChangeExternallyNotification通知我NSUbiquitousKeyValueStore (我使用同步的NSUserDefault键值),并且这些通知转学过来的和更新没有任何的毛病可言,这让我困惑,甚至更多,为什么persistentStoreCoordinator通知是空白。

我真的希望有人以前曾经看过/经历过这个问题,因为经过两周的时间,我想尽一切办法自行找到并解决此问题,我现在处于停滞状态。

我已经弄清楚了。 基本上,事务日志似乎已损坏或放错了位置。 我已经重新设计了重新定型设备的方法,并将结果立即发布到我的上一个问题上

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM