Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSPersistentCloudKitContainer with CKAsset?
Trying to figure out the best way to update an CoreData app to use Cloud Kit.Right now I have a ObjectA entity defined as the top level object. There is a Photo entity that contains a Binary Data attribute for the thumbnail and a URI for the location of the full image. So bascially that setup is a lot like a CKAsset in CloudKit and CKAsset would seem to be the logical way to get the images to sync between devices.I can't find anything along those lines relating to NSPersistentCloudKitContainer though. As the model is taken from Core Data model you can't really predefine an asset attribute. So would the approach be to get the CKRecord and directly add the CKAsset that way? Would there be repercussions related to the Container if you did that?And if there is some simpler way I am missing please let me know. I am aware I can do a Binary Data attribute, I had done that earlier in the app's life and it didn't work as well as just providing the URI for the image and managing the data myself. Or would that
0
0
736
Aug ’19
NSPersistentCloudKitContainer stops syncing
I have moved my NSPersistentContainer in my app to an NSPersistentCloudKitContainer to sync data between devices (iPhone, iPad, and Apple Watch supported). Sync works just fine in test & production, but after a few days it will stop working and behave as if each device is using local storage. This continues to happen until I reinstall the app and it syncs again, but only for a short time until it goes back to using local storage again. Does anyone know of a way to debug this?
3
0
882
May ’20
Callback support for NSPersistentCloudKitContainer in iOS14 beta
The callback from syncing of NSPersistentCloudKitContainer is mostly added from iOS14 onwards. I got to know that NSPersistentCloudKitContainer.Event helps to understand sync status of data from CoreData to CloudKit. Use Case: I need to understand the sync status of data from watch to Cloudkit, so that I can choose to send it explicitly to companion phone or not. Has anybody got leads how to use make use of the newly released features forNSPersistentCloudKitContainer in iOS14? For reference : [https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer)
2
0
791
Aug ’20
How to debug NSPersistentCloudKitContainer background updates?
I have been using NSPersistentCloudKitContainer in my app for a while now. My main issue at the moment is that even though I have followed all of the documented steps for setting up background silent notifications, they don't seem to be working. (I query for the Core Data state from a Shortcut/Intent and can verify that the Core Data store hasn't been updated.) This hasn't been too much of an issue, but with new system features like widgets (WidgetKit), this is an issue I can no longer ignore. I'm not sure if it's completely out of my control (e.g. the OS just has decided not to deliver the notifications in the background) or if there's some undocumented step I need to take to ensure it is set up correctly. Has anyone gotten background syncing to work properly with NSPersistentCloudKitContainer? Did you have to do anything special to get it to work? Any tips for debugging what might be going wrong?
5
0
1.4k
Jul ’20
NSPersistentCloudKitContainer and App Extensions
Can the behavior of NSPersistentCloudKitContainer be described in App Extensions? I have seen Forum entries that describe its behavior in Widgets - it will save data locally, but will not sync that data until the app is opened. This is a pretty major downsides for any apps that use SiriKit Extensions to allow for quick, simple data entry -- not syncing the data until the app is opened (which could be days later) would be a deal breaker. I hope this can be clearly described, and improved (if my understanding is correct) - I've filed a feedback to document this as well: FB9170155
0
0
945
Jun ’21
NSPersistentCloudKitContainer not saving 50% of the time
I'm using NSPersistentCloudKitContainer to save, edit, and delete items, but it only works half of the time. When I delete an item and terminate the app and repoen, sometimes the item is still there and sometimes it isn't. The operations are simple enough: moc.delete(thing) try? moc.save() Here is my DataController. I'm happy to provide more info as needed class DataController: ObservableObject { let container: NSPersistentCloudKitContainer @Published var moc: NSManagedObjectContext init() { container = NSPersistentCloudKitContainer(name: AppName) container.loadPersistentStores { description, error in if let error = error { print(Core Data failed to load: (error.localizedDescription)) } } #if DEBUG do { try container.initializeCloudKitSchema(options: []) } catch { print(Error initializing CloudKit schema: (error.localizedDescription)) } #endif moc = container.viewContext } }
2
0
405
Nov ’24
NSPersistentCloudKitContainer/Core Data design approach
I'm using NSPersistentCloudKitContainer together with a private and public database. I have a public database with articles. Users should be able to like an article but I'm wondering what would be the best design approach to achieve this. The users can also add articles that they find online which are then automatically liked for the user adding it (and uploaded to the public database) Question 1 I want you to be able to see how many people have liked an article, so I think there will perhaps be an array on the article with the userId who liked it and then you just do a count on it? Or do you think there is a better way? Question 2 I am thinking about how the liked article should be saved for the user, either put that article in their private database, but then that article will be disconnected from the public article. Or I can filter out among the public articles that contain the user's userId (however, I'm a little unsure how it works in practice as the public database is polled every 30 minutes wi
0
0
845
May ’23
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
Reload NSPersistentCloudKitContainer from a SwiftUI View - MVVM
How can I reload the NSPersistentCloudKitContainer from a SwiftUI View? I have a SwiftUI + MVVM + CloudKit app that successfully syncs to CloudKit but what I would like to be able to do is reload the NSPersistentCloudKitContainer from some View in the app to be able to evaluate if the app should sync to CloudKit or not by setting the cloudKitContainerOptions to nil (description.cloudKitContainerOptions = nil) if the user doesn't want to sync. In other words, I need to reload the code inside the init() method in the CoreDataManager file when a method in the View Model is called. See the code and comments below. Here is the code... Core Data Manager class CoreDataManager{ static let instance = CoreDataManager() let container: NSPersistentCloudKitContainer let context: NSManagedObjectContext init(){ container = NSPersistentCloudKitContainer(name: CoreDataContainer) guard let description = container.persistentStoreDescriptions.first else{ fatalError(###(#function): Failed to re
1
0
790
Jan ’22
NSPersistentCloudKitContainer not syncing existing data
I'm running into trouble setting up sync using NSPersistentCloudKitContainer on an existing app. The app doesn't seem to sync data that was added to Core Data prior the app's iOS 13 update. For instance:1. I install an existing, pre-iOS 13, version of the app and create several records that are stored in Core Data.2. Over that existing install, I install the updated version that uses NSPersistentCloudKitContainer and create some additional new records.3. I install the same new version on a second device.Results: Records created in step 1 don't appear on the second device, but records created in step 2 do.Is there a step I'm missing in order to get existing data to sync? I'm wondering if this has something to do with the persistent history token, but I'm unsure how to tell NSPersistentCloudKitContainer it should start over on first launch.
22
0
15k
Jul ’19
Share an object managed by NSPersistentCloudKitContainer with other users
One question I often see on DevForums and in my day DTS job is if a Core Data object managed by NSPersistentCloudKitContainer can be shared with other iCloud users. The answer is yes but you need to do it using CloudKit API directly because NSPersistentCloudKitContainer doesn’t support CloudKit shared database (CKContainer.sharedCloudDatabase) today. Assuming you have a Core Data object, let’s say a document, that you’d like to collaborate with your colleagues: You are the document owner and can use NSPersistentCloudKitContainer to fully manages the document and synchronize it across your devices. You can grab a CloudKit record associated with your document from NSPersistentCloudKitContainer using record(for:) or recordID(for:), and share it to your colleagues using UICloudSharingController. See our Sharing CloudKit Data with Other iCloud Users - https://developer.apple.com/documentation/cloudkit/sharing_cloudkit_data_with_other_icloud_users sample for how to share a CloudK
2
0
977
Sep ’20
NSPersistentCloudKitContainer "migrate to a completely new store"?
I have a model that has already been pushed to production, and I would like to move an attribute to a new entity as a relationship.From This:extension Note { @NSManaged public var drawingData: Data? .... }To This: extension Note { @NSManaged public var drawing: Drawing? .... } extension Drawing { @NSManaged public var drawingData: Data? .... }According to the Apple Docs under the Update your Production Schema section, I will need to migrate to a new CloudKit Container, since we can't delete attributes on production CKRecords.What is the proper workflow to do this?I have come up with the following, but I believe it is wrong.lazy var oldPersistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Model) let storeLocation = URL(fileURLWithPath: /path/to/cloud.store) let storeDescription = NSPersistentStoreDescription(url: storeLocation) // Set the container options on the cloud store cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloud
1
0
1.5k
Mar ’20
Restart sync when using NSPersistentCloudKitContainer
It's 2024, and it still seems like the only sure way to cleanly restart cloud sync on an app using NSPersistentCloudKitContainer is to uninstall and reinstall the app. No need to describe how bad that solution is... Am I missing something? Is there a better way to safely trigger such a restart of the sync (even if it means losing unsaved data and overwriting with what's in the cloud - which is what a reinstall does anyway)?
2
0
725
May ’24
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-sharemanagedobjects 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? A similar question was posted here with no response: https://developer.apple.com/forums/thread/697630
1
0
901
Jun ’22