我在 iOS15 beta 4 上使用 NSPersistentCloudKitContainer 来跨设备同步核心数据。在设备上启动并登录 iCloud 时,我在日志中收到以下错误:
我有以下代码:
init(inmemory: Bool = false) {
container = NSPersistentCloudKitContainer(name: "AppName")
if inmemory {
let storeDescription = NSPersistentStoreDescription(url: URL(fileURLWithPath: "/dev/null"))
container.persistentStoreDescriptions = [storeDescription]
} else {
let storeURL = URL.storeURL(for: "my.app.group",databaseName: "AppName")
let storeDescription = NSPersistentStoreDescription(url: storeURL)
storeDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.my.app")
container.persistentStoreDescriptions = [storeDescription]
}
container.loadPersistentStores(completionHandler: { (storeDescription,error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error),\(error.userInfo)")
}
})
}