Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Initialize NSPersistentCloudKitContainer with iOS 14 and Public DB
I'm struggling to initialize my schema. I keep getting the error : Error Domain=NSCocoaErrorDomain Code=134060 A Core Data error occurred. UserInfo={NSLocalizedFailureReason=Couldn't initialize CloudKit schema because no stores in the coordinator are configured to use CloudKit Without the initialize it does sometimes create the record's schema. But it feels like its all half working. I have Cloudkit on and Used with Cloudkit is checked under the default configuration in my xcdatamodeld file. Here is my setup code.. _persistentContainer = [[NSPersistentCloudKitContainer alloc] initWithName:@Eco-nomy]; // Add options and make this container PUBLIC. NSPersistentStoreDescription *description = _persistentContainer.persistentStoreDescriptions.firstObject; [description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentHistoryTrackingKey]; [description setOption:[NSNumber numberWithBool:YES] forKey:NSPersistentStoreRemoteChangeNotificationPostOptionKey]; description.cloudKitContainerOptions.databas
0
0
736
Feb ’21
How to handle UX of iCloud Sync with NSPersistentCloudKitContainer?
I'm adding iCloud sync using NSPersistentCloudKitContainer to my production app. When the user firsts downloads the app, they are prompted to create a profile (they basically just choose an icon representing something). There's no email address or anything, and the user can create multiple profiles to track different things. Now that there's iCloud sync, if a user downloads the app on an iPad after using it on their phone, they are still prompted to create a profile. There's no way around this as far as I can tell, because you cannot manually trigger a sync and it sometimes takes a full 5 minutes for NSPersistentCloudKitContainer to decide to sync. How do I handle the UX of this? I don't want the user to have to create a new profile and then delete/merge it once the data comes in, but I can't rely on iCloud syncing in time to handle this case. Any advice would be really appreciated.
0
0
880
Mar ’21
Using Core Data With CloudKit
Hi, I have NSPersistentCloudKitContainer and everything is great until I faced the issue after a while of using it. It takes so long to sync because its loading all the changes that was done on the object and doesn't just fetch the latest values of the object. My solution now is to manually fetch CKRecords to see if there is something or not. If so I'm displaying Loading while CoreData and CloudKit find their way to sync. Thanks
0
0
560
Apr ’21
Reply to Is it safe to use a NSPersistentCloudKitContainer on a Share Extension?
Having used this API for two of my apps, and speaking with an Apple engineer, it sounds like we can assume the following: NSPersistentCloudKitContainer can be safely used in a Share Extension for storing data locally. It will complete the save operation locally. Uploading to CloudKit requires a scheduled background operation on the part of the API. Because of this, by the time the Extension is terminated, the background operation is not completed, and thus the CloudKit sync does not occur. In my testing, this leads to predictable behavior: Data is never uploaded from an Extension, however, Data is saved locally in your persistent container. And upon launching your app, with the container alive once more, it will sync your data to CloudKit. It's a bit unwieldy having to launch your app after an operation in an Extension, but from my own usage, I think it's safe to say that you can safely use NSPersistentCloudKitContainer, even if it doesn't sync as you or I would like. I truly hope this behav
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’21
NSPersistentCloudKitContainer - how to reset CoreData+CloudKit after failed automatic migration (while still in development environment)
I have expanded my CoreData model quite a few times, including renaming entities, properties (and as far as I remember relationships). I am still working in the (CloudKit) development environment, only. Now I am getting errors each time I start the app (one line out of many shown): CoreData: debug: CoreData+CloudKit: -PFCloudKitMetadataModelMigrator calculateMigrationStepsWithConnection:error:(404): Skipping migration for 'ANSCKDATABASEMETADATA' because it already has a column named 'ZLASTFETCHDATE' The app is working as expected, it seems this error has no effect on correct CoreData+CloudKit execution. But I want to get rid of this error warning before I deploy to production for TestFlight or expand CoreData further. To have a clean CD+CK base I can start migrations from in future. Can I just reset CD (or CoreData's model) to make CD accept the current model as the base model without any migrations attached to it? An Apple Engineer suggested here - https://developer.apple.com/forums/thread/47637?answerId=146
3
0
2.9k
Apr ’21
Cloudkit Share Updating Core Data NSManaged Objects
I have a simple shopping list app that is using Core Data with Cloudkit. A user creates a list then adds items to the list. The list can be shared to other users. Core Data is first used to save the Lists and Items as NSManaged Objects. A list is then shared to another user who can add to items to the list, and both users working on the same list stay in sync with each other. This is all mostly working but I am having some trouble getting Core Data to update the locally stored NSManaged objects with changes from the Cloud Kit Share. Currently the app is dealing with a mix of NSManaged Objects and CKRecords to display in the table View that shows the items on a list. Which is a bit messy. I really want to just work with NSManaged Objects with Cloudkit doing the work of keeping things in sync between the 2 users. When User B adds an Item it successfully saves to the Shared Database and sets the parent as the list that was shared. This is where I get a bit stuck as I want User A to see the Item that User B added
0
0
701
Apr ’21
CoreData • How to perform Lightweight-Migration when using NSPersistentCloudKitContainer?
I am developing an App using CoreData & CloudKit (NSPersistentCloudKitContainer). I am working on an App Update which includes an Update to the CoreData Model. I have created a new Model Version and applied the Changes (including new Properties & Relationships as well as Renaming of Entities & Properties). For Renaming I set the Renaming ID to the old Entity- / Property-Name. These Changes should be supported by Lightweight-Migration. Questions Is there anything else I have to consider when updating a CoreData Model or did I cover all? What about the CloudKit Synchronization? How does CloudKit handle the CoreData Model Update? I read about adding this Method *(initializeCloudKitSchemaWithOptions)* during Development and removing it when deploying to Production. What does this Method do exactly? Thanks a lot for your help in Advance. This is quiet a huge Update and the App does have an existing Userbase, so Migration-Problems are no Option;)
0
0
903
May ’21
CloudKit CoreData not syncing on WatchOS
I have a watchOS extension that I'm trying to sync to their iPhone using CoreData and CloudKit, but it doesn't seem to want to sync. I've tried a few solutions (CloudKit + CoreData on iOS and watchOS sync not working, Core data + CloudKit - sharing between iOS and watchOS companion app), but it's still not syncing. Here's my shared (it's loading in both targets) persistence code: import CoreData struct PersistenceController { static let shared = PersistenceController() static var preview: PersistenceController = { let result = PersistenceController(inMemory: true) return result }() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: My-app) if inMemory { container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: /dev/null) } let description = container.persistentStoreDescriptions.first description?.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCloud.com.mydomain.my-app
1
0
1.8k
May ’21
How can I get NSPersistentCloudKitContainer working with UICollectionViewDiffableDataSource
I am trying to get CoreData(Sync'd via NSPersistentCloudKitContainer, although that is not particularly relevant for the current issue) to play nicely (or even at all) with UICollectionViewDiffableDataSource. The stumbling block seems to be concerned with [NSManagedObject hash]. I need the diffing engine to notice a change when there is a change in the specific managedObject-subclass, AND/OR (at least some) of its child managedObject-subclasses. Example: So, in the above example object graph, I need the Posts datasource to notice when the 'name' of the Tag changes, and react accordingly. i.e. {Post.tags.any.name} The simplest solution would be if I could override[Post hash], but of course that's not allowed. Even obj-c method-swizzling does not work without complaining. Class 'Post' for entity 'Post' has an illegal override of NSManagedObject -hash Adding 'computed values' with the parent managed-object does not work; computed vars don't seem to be included in the [hash] implementation. Any ideas wha
0
0
813
Jun ’21
NSPersistentCloudKitContainer support for CloudKit Record Zone Sharing
NSPersistentCloudKitContainer now supports sharing via CloudKit Record Zone Sharing. This new capability allows applications to easily build features that enable sharing of Core Data managed objects with multiple iCloud users. We've updated our sample application and documentation to demonstrate how these new capabilities work. At a high level NSPersistentCloudKitContainer now supports: New API for binding directly to call sites commonly used for sharing in your AppDelegate, UICloudSharingController, or your user interface code. Assigning the .shared database scope to instances of NSPersistentCloudKitContainerOptions Sharing of managed objects to single CKRecordZone Direct access to read or write the CKShare for a managed object via new API on NSPersistentCloudKitContainer. For more information be sure to watch our session Build apps that share data through CloudKit and Core Data on Friday.
1
0
858
Jun ’21