簡體   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