Hi,
I'm using CoreData+CloudKit in a blank universal project for macOS 11 and iOS14.
The records are in a private database inside a custom zone, I was able to set the correct database, but I'm yet to be able to set the zone.
On the PersistentController created by default by Xcode 12 I have the following code
And inside a View
I've searched around the web and in apple docs but I haven't found an updated way to do this.
I'm using CoreData+CloudKit in a blank universal project for macOS 11 and iOS14.
The records are in a private database inside a custom zone, I was able to set the correct database, but I'm yet to be able to set the zone.
On the PersistentController created by default by Xcode 12 I have the following code
Code Block let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: "finances_manager_pro") let customZone = CKRecordZone(zoneName: "CloudCore") guard let description = container.persistentStoreDescriptions.first else { fatalError("Error") } description.cloudKitContainerOptions?.databaseScope = .private if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null") } container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } }) }
And inside a View
Code Block @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: \ExpenseCoreData.timestamp, ascending: true)], animation: .default) private var items: FetchedResults<ExpenseCoreData>
I've searched around the web and in apple docs but I haven't found an updated way to do this.