【问题标题】:UIManagedDocument doesn't import iCloud changesUIManagedDocument 不导入 iCloud 更改
【发布时间】:2016-09-18 12:55:25
【问题描述】:

当我在设备 A 上打开一个UIManagedDocument(在一个普遍存在的容器内)时,在设备 B 上对该文档进行更改时,这些更改不会导入到设备 A 上的 CoreData 堆栈中。

我看到更改到达设备 A 是因为在文档上调用了方法 presentedSubitemDidChangeAtURL()。 如果我关闭并重新打开文档,我会看到这些更改。

但我希望UIManagedDocument 在文档打开时自动将这些更改合并到托管对象上下文中。不是这样吗?文档并没有说我必须自己做。


我用

创建我的文档
let document = UIManagedDocument(fileURL:...)
document.persistentStoreOptions = [NSMigratePersistentStoresAutomaticallyOption: true, NSInferMappingModelAutomaticallyOption: true]

并将其移至 iCloud

let fileManager = NSFileManager()
fileManager.setUbiquitous(true, itemAtURL: documentURL, destinationURL: url)

【问题讨论】:

    标签: ios core-data icloud uimanageddocument


    【解决方案1】:

    在获得 Apple 开发者技术支持的帮助后,发现在设置持久化商店时必须包含 NSPersistentStoreUbiquitousContentNameKey

    【讨论】:

      猜你喜欢
      • 2012-04-10
      • 2013-12-24
      • 2012-05-25
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 2012-09-27
      • 2017-02-18
      • 2013-11-30
      相关资源
      最近更新 更多