Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

Reply to CloudKit and CoreData public database
More info: I have experimented with code similar to yours to initialize two CloudKit schemas with one single request on the single NSPersistentCloudKitContainer instance. It does indeed work, however,there are limitations with the Xcode schema designer which render the results, effectively useless. The problems start when you create multiple configurations in your schema model, that are declared to be used with CloudKit. The schema designer has no knowledge of container identifiers, nevermind multiple container identifiers. I discovered that as soon as I added a new CloudKit backed configuration and added a single new entity to it with zero relationships, my project no longer compiled. Xcode told me that I had to add the entities from the other CloudKit backed configuration to this new configuration with it's single isolated entity. Bizarrely, it never instructed me to add the new isolated entity to the previous CloudKit configuration. It was complaining about relationships in the older CloudKit conf
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19
CD4CK wont initialize CloudKit schema
By the time this debug output is printed, I've loaded 2 store descriptions, into a NSPersistentCloudKitContainer, that both have the NSPersistentCloudKitContainerOptionsKey set, both with differing containerIdentifiers that exist in iCloud. Yet, attempting to initialize the schema fails saying none of my store descriptions in the coordinator are configured to use CloudKit. They definitely are configured in the MOM. Other observations: I'm beginning to think it's not advisable to have 2 configurations in one MOM that both point to different iCloud containers, because Xcode tells me that I have to add entities from one CloudKit configuration into another CloudKit configuration in order to get it to compile. Yet the one configuration contains just a single entity with no relationships at all. So that's really unexpected. Will Core Data attempt to generate CKRecords in both containers for the entities that appear in both CloudKit configurations? Perhaps it's best to use seperate MOMs (and an associated NSPersistentCloudKitContainer
1
0
1.8k
Aug ’19
Reply to CloudKit and CoreData public database
I believe that yes, it will create two stores and two different containers with private databases. I used to think, incorrectly, that there was a 1 to 1 mapping between an instance of NSPersistentCloudKitContainer, and a single CloudKit store description, but I've come to realize that one instance can handle multiple cloud synced stores.When working with multiple stores, create an instance of NSPersistentCloudKitContainerOptions for each store you wish to use with CloudKit.And no, you can't access the public, or shared database with Core Data for CloudKit. Also, if you want to write to the public database but not as an individual user, you can't do that through the iOS CloudKit API. CloudKit CKRecord instances are always owned by the user who created them. You'd have to use a server to server key and use their REST API from your app. That way you can write records as admin. I was thinking of using the public database to store app configuration data, but I'm not sure I want to develop with yet another
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19
CloudKit and CoreData public database
Core Data with CloudKit uses a specific record zone in the CloudKit private database, which is accessible only to the current user.It's not possible to use CloudKit and CoreData with the CloudKit public database? Here is my scenario.- I have an application with two core data stores.- The first store should be synced with the public CloudKit database and NOT updated by the user.- The second store should be synced with the private CloudKit database and updated by the user.lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: MyAppName) // Create a store description for the first store let firstStoreLocation = URL(fileURLWithPath: /path/to/first.store) let firstStoreDescription = NSPersistentStoreDescription(url: firstStoreLocation) firstStoreDescription.configuration = First // Create a store descpription for the second store let secondtoreLocation = URL(fileURLWithPath: /path/to/second.store) let secondStoreDescription = NSPersiste
2
0
4.7k
Aug ’19
Reply to NSPersistentCloudKitContainer for Shares
NSPersistentCloudKitContainer does not support sharing. Please file a feedback report with your intended sharing use case, data model, and any specific design requirements you have regarding the sharing experience.As others have (correctly) pointed out, NSPersistentCloudKitContainer maintains a specific zone in the private database, and therefore will never see any shared zones owned by other users.You can implement sharing yourself using the standard CKShare / CKRecord APIs.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19
Reply to NSPersistentCloudKitContainer not syncing existing data
Do these records have entries in persistent history? Without them NSPersistentCloudKitContainer can't see the records.This is by design. However we will take your feedback reports on this issue as an enhancement request to make it easier to use NSPersistentCloudKitContainer with existing store files.Keep filing them. Include a sysdiagnose and the persistent store files if you can.
Aug ’19
CD4CK: Can't find Default configuration in M.O.M.
There are a few things about how Core Data 4 Cloud Kit initializes that I'm stuggling to understand. I've spent most of the day finally getting a schema initialized on the server, and learnt a few things along the way.Firstly, even though I have a Default configuration in my managed object model, and it has been there from day one with the option Used with CloudKit checked for true, if I create an `NSPersistentStoreDescription` and set the configuration property to Default, when I try to load the stores, it will fail, saying Unable to find a configuration named 'Default' in the specified managed object model.. If I inpsect the debug description for my ManagedObjectModel instance, it does indeed not have any reference to the string Default in it (I'm not sure if debugDescription is actually printing out the configuration names however). Why does this fail? I can only get my store loaded and the schema initialized if I remove the code that sets the configuration name to Default.The next thing that tripped me up
2
0
1.7k
Aug ’19
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: How to know initial sync between CloudKit has happened?
I am looking into using the new NSPersistentCloudKitContainer to sync some internal data for my app. Generally it works great, but I have one scenario that I cannot figure out.Here the basic scenario, there is a single record in CloudKit that created and used to keep track of some internal state. Keeping it the cloud allows for two cases: when the user open the app on another device (say an iPad) and when the user re-installs the app on the same device.If its indeed the very first time the user is using the app on any device, I need to create the record with a bunch of default initial values. I am okay with spending a little time at app startup determining if its a brand new user or an existing user installing on another device.I thought maybe observing NSPersistentStoreRemoteChangeNotification would provide a useful point in time that I can say ah ha, now I know its a new user, or an existing user. However its gets called a lot and I cannot find anything in its userInfo that gives me a definitive an
4
0
3.8k
Aug ’19
Reply to How do I create a variable for NSPersistentContainer and NSPersistentCloudKitContainer with the same name but set depending on the version?
That worked purfectly, thank you so much! I honestly did not try that becouse I did not think it would work with line one and three in that block of code. I did not know that even though you set persistentContainer with type of NSPersistentContainer that you could alter that with type NSPersistentCloudKitContainer on line three. I will have to keep that in mind for the furture, thank you.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’19
Reply to How do I create a variable for NSPersistentContainer and NSPersistentCloudKitContainer with the same name but set depending on the version?
Why don't you use `if #available` ? lazy var persistentContainer: NSPersistentContainer = { if #available(iOS 13.0, *) { let container = NSPersistentCloudKitContainer(name: Shopping_App) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) return container } else { let container = NSPersistentContainer(name: Shopping_App) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) return container } }()
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’19
How do I create a variable for NSPersistentContainer and NSPersistentCloudKitContainer with the same name but set depending on the version?
I cannot change my existing core data stack to NSPersistentCloudKitContainer because that is only a iOS 13 and later support feature but I would like to have that set for iOS 13 and later while having NSPersistentContainer for earlier versions.I have a decent amount of experience working with swift and iOS but have not ever had to do something like this for versioning and certain vars/lets on certain verions.This is my code for my coredata stack for the iOS 13 and later for NSPersistentCloudKitContainer: lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: Shopping_App) container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (error.userInfo)) } }) return container }()This is my code for iOS 12 and earlier: lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: Shopping_App
2
0
1.1k
Aug ’19
Reply to Value of type 'NSPersistentCloudKitContainerOptions' has no member 'shouldInitializeSchema'
For anyone else finding this:You need to call container.initializeCloudKitSchema() after container.loadPersistentStores.You don't really need to call container.initializeCloudKitSchema() at all, as CloudKit will create your schema on the fly. initializeCloudKitSchema just sends some fake data for your model, so it's handy to see if anything's going to break that Xcode didn't warn you about.Here's some code that works in Xcode 11 beta 5 to initialize an NSPersistentCloudKitContainer using a local store and a cloud store (see the Manage Multiple Stores section of the Setting Up Core Data doc). // MARK: - Core Data stack /// Convenience method so you can do DataManager.shared.context instead of DataManager.shared.persistentContainer.viewContext. lazy var context = self.persistentContainer.viewContext /// persistentContainer.viewContext lazy var persistentContainer: NSPersistentContainer = { /* The persistent container for the application. This implementation creates and returns a container, having loade
Aug ’19
Reply to cloudkit sync not getting cloudkit updates
It works in the simulator but syncs only on app startup when you set the automaticallyMergesChangesFromParent-option on the viewContext. See https://stackoverflow.com/questions/56601716/how-to-get-default-project-with-nspersistentcloudkitcontainer-up-and-runningThe actual sync via push notification only works on real devices.
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’19