簡體   English   中英

核心數據+ iCloud Sync NSPersistentStoreDidImportUbiquitousContentChangesNotification

[英]Core data + iCloud Sync NSPersistentStoreDidImportUbiquitousContentChangesNotification

我正在經歷核心數據和iCloud同步的一些有線行為。 我在我的應用程序中添加了iCloud文檔和Cloudkit功能,並訂閱了這三個通知:

NSPersistentStoreCoordinatorStoresWillChangeNotification
NSPersistentStoreCoordinatorStoresDidChangeNotification
NSPersistentStoreDidImportUbiquitousContentChangesNotification

我第一次運行應用程序時收到了這些通知:

Using local storage: 1
store will Change notification
store did Change notification
Using local storage: 0

但是,NSPersistentStoreDidImportUbiquitousContentChangesNotification沒有被解雇,因為核心數據沒有從我的iCloud帳戶無處不在的容器中下載數據。

但是,當我退出應用程序並在啟用飛行模式時重新啟動它時,我的所有數據都立即加載。 似乎第一次啟動時數據已下載並保存到SQLite存儲,但未通知通知,因此我的UI可以刷新。

有沒有人經歷過這樣的事情,你在那種情況下做了什么。

首次設置和“正常”同步操作之間存在差異。

在首次設置期間不會發布NSPersistentStoreDidImportUbiquitousContentChangesNotification ; 只有在以后發生變化時。 這會通知應用程序導入它們(通過調用mergeChangesFromContextDidSaveNotification(_:) )。

Apple的CoreData iCloud編程指南非常有助於理解在哪個階段發生的事情。

請特別參閱有關iCloud的章節,從iCloud執行一次性設置核心數據發布內容更改

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM