Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSPersistentCloudKitContainer - mirror sync
My app uses a mirrored CoreData Store with NSPersistentCloudkitContainer. The user has the option to turn cloudKit sync on or off by device. The app responds by setting the description?.cloudKitContainerOptions = nil - but keeps historyTracking on by setting description?.setOption(true as NSNumber,forKey: NSPersistentHistoryTrackingKey) The app is working fine this way with multiple devices and if the user re-enables sync on a particular device that was either disabled or offline everything syncs just fine on all devices. I now want to prune History transactions and I intend to clear the history older than say 7 days only when I receive a NSPersistentStoreRemoteChangeNotificationPostOptionKey observation on transactions that are outside the app. Does a device that was either offline or had sync disabled as per above then re-enabled or come back online upload its local changes first then download changes from the store? I am concerned that if is not this way I will potentially have to keep all History
0
0
710
Dec ’21
NSPersistentCloudKitContainer reverts NSManagedObject subclass to old value
I have an app that uses NSPersistentCloudKitContainer to synchronise data with iCloud. Users reported occasional data loss after which I started debugging my implementation.Part of my app’s implementation is showing a pop-up that displays information and has a confirm button. When the user clicks this button, one or more instances of a custom NSManagedObject subclass gets modified.At the same time, NSPersistentCloudKitContainer triggers a mirror process when the app resigns and becomes active. This happens when the user clicks the above mentioned confirm button. It does this by executing a NSCloudKitMirroringExportRequest and NSCloudKitMirroringImportRequest request.In other words, in my app, data gets modified (explicitly via code) and gets mirrored (implicitly via CloudKit) at the same time, and this is where things go wrong.Essentially this is what happens:1. A property (NSTimeInterval) of an instance of an NSManagedObject subclass gets incremented (e.g. 0 + 1 = 1).2. NSPersistentCloudKitContainer
2
0
1.3k
Apr ’20
NSPersistentCloudKitContainer CoreData & CloudKit Sync Crash
I am using the new iOS 13 NSPersistentCloudKitContainer for Syncing CoreData with iCloud.For large size binary data i am using Allow External Storage in Core Data Model.• I successfully added 200MB sized video on one device.• It got synced to iCloud successfully.• On the other device, when i am opening the App, it is receiving the CloudKit record, but somehow not able to work properly.There is no programming error from my end. I have made sure that in CoreData Model Allow External Storage is selected. Looks like it has something to do with how NSPersistentCloudKitContainer imports the large binary data.Errorerror: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x2805386c0> , *** NSAllocateMemoryPages(227428466) failed with userInfo of (null)CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x2805386c0> , *** NSAllocateMemoryPages(227428466) failed with userInfo of (null)2020-01-18 20:52:24
2
0
1.8k
Jan ’20
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
Can I access CloudKit's metadata fields with NSPersistentCloudKitContainer?
I've got a simple Core Data Entity that is synchronized with CloudKit via NSPersistentCloudKitContainer. I can read my local fields, but how can I read fields like Created & Modified from CloudKit? Do I have to add them to my Core Data model and populate them myself? P.S. In his fantastic WWDC talk Using Core Data with CloudKit, at around 21:40, Nick Gillet talks about how Core Data entities in the CloudKit store are prefixed with CD_ to separate the things that it manages from the ones CloudKit implements. Then he says: You wouldn't believe how many people add modify date to their CKRecord. Like it's something redundant.
0
0
633
Aug ’23
NSPersistentCloudKitContainer losing data
Some users of my app are reporting total loss of data while using the app. This is happening specifically when they enable iCloud sync. I am doing following private func setupContainer(enableICloud: Bool) { container = NSPersistentCloudKitContainer(name: ) container.viewContext.automaticallyMergesChangesFromParent = true container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy guard let description: NSPersistentStoreDescription = container.persistentStoreDescriptions.first else { fatalError() } description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) if enableICloud == false { description.cloudKitContainerOptions = nil } container.loadPersistentStores { description, error in if let error { // Handle error } } } When user clicks on Toggle to enable/disable iCloud sync I just set the description.cloudKitContainerOptions to nil and then user is asked to restar
4
0
1.1k
Sep ’24
Using NSPersistentCloudKitContainer causes crash for iOS 14
In iOS 14, I am trying to use the NSPersistentCloudKitContainer, but there is a crash with the following error message: ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Must register a handler for activity identifier com.apple.coredata.cloudkit.activity.export.[an UUID] before submitting it' terminating with uncaught exception of type CKException Does anyone else have this error? Is there any workaround for this? I have already filled a bug report FB8618522 Thanks in advance!
11
0
3.2k
Sep ’20
NSPersistentCloudKitContainer exclude relationship from share
I am trying to add CloudKit sharing to my app using the new iOS 15 share method https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3746834-share In the app there are 3 core data entities (Folder, Item, Comment) with the following relationships: A Folder contains many Items An Item has many Comments I want to use CloudKit to share just the Item entity, not any of its relationships. Is this possible to do with the share(_:to:completion:) method? Currently, when I pass an Item to the share method it also includes the Folder and Comments in the CKShare. How do I prevent this?
1
0
977
Feb ’22
NSPersistentCloudKitContainer data loss edge case
Hi, I was testing the new iOS 18 behavior where NSPersistentCloudKitContainer wipes the local Core Data store if the user logs out of iCloud, for privacy purposes. I ran the tests both with a Core Data + CloudKit app, and a simple one using SwiftData with CloudKit enabled. Results were identical in either case. In my testing, most of the time, the feature worked as expected. When I disabled iCloud for my app, the data was wiped (consistent with say the Notes app, except if you disable iCloud it warns you that it'll remove those notes). When I re-enabled iCloud, the data appeared. (all done through the Settings app) However, in scenarios when NSPersistentCloudKitContainer cannot immediately sync -- say due to rate throttling -- and one disables iCloud in Settings, this wipes the local data store and ultimately results in data loss. This occurs even if the changes to the managed objects are saved (to the local store) -- it's simply they aren't synced in time. It can be a little hard to reprodu
3
0
291
2w
Is there any way to observe the sync status of an NSPersistentCloudKitContainer?
I believe that right now there's no way to be notified when the sync status of an NSPersistentCloudKitContainer changes. Is my assumption correct? I'd like to know if there are pending changes to be synced or when the sync starts/ends to be able to reflect it on the UI to inform my users. Any ideas on how (or if it's possible) to achieve what I need? Thank you!
1
0
1.1k
Jul ’20
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
NSPersistentCloudKitContainer can't get record from NSManagedObjectId
I try to figure out if it's possible to share a users core data events in one app, to another user with CKShare and CKRecord.I got the device sync up and running and can see the changes, also CloudKit dashboard has published the changes to production.However, when I have my NSManagedObject that I got either local or from another device, I try to call the following:let myEvent: // NSManagedObject from core datalet container: NSPersistentCloudKitContainer = AppDelegate.shared.containerlet record = container.record(for myEvent.objectID // not working// record is always nilThe receord is always nil, why?And is is possible to later pass the CKRecord in a UICloudSharingController to share it to another user?
4
0
1.6k
Jun ’19