Search results for

“NSPersistentCloudKitContainer”

601 results found

Post

Replies

Boosts

Views

Activity

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
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
Reply to NSPersistentCloudKitContainer not syncing existing data
Just utilizing the container doesn't enable the sync. You have to add/request the capabilities throuigh your plist file (iCloud under capabilities, may require background too, but i'm unsure). Pretty sure you need remote notifications as well. I read on a blog somewhere a step by step to get it working, but I haven't found 'Official' instructions for anything more than the class declaration yet. I 'think' I googled NSPersistentCloudKitContainer and tutorial.. or maybe getting started.
Jul ’19
Reply to NSPersistentCloudKitContainer for Shares
The presenter at WWDC 2019 (Nick Gillett) mentioned that Apple maintains a custom Zone in the private database (around 10:50 in the video).Since records get saved in the private database, I would think that CKShares and NSPersistentCloudKitContainer are a no-go combo.But, according to Apple's documentation, you can access the CKRecord for a specific managed object using dedicated methods, which will allow you to create CKShares: https://developer.apple.com... So I am confused.
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’19
Reply to NSPersistentCloudKitContainer for Shares
I've been waiting on CloudKit + CoreData integration for a while, and I don't see how NSPersistentCloudKitContainer can't be used to share. Zero of my users has asked to sync the data between devices, everyone wants to share it between users, and how is such a core feature missing?Have to say, I'm not sure if it's missing because I can't find any documentation or tutorials, but it sure looks that way!
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’19
Posts Sample Application for 'Using Core Data with CloudKit'
The session Using Core Data with CloudKit (https://developer.apple.com/videos/play/wwdc2019/202/) spoke of a sample app for demonstrating the new NSPersistentCloudKitContainer and how it ties Core Data and CloudKit together. I didn't see it listed with the session resources; has it been uploaded somewhere else? If not, when can we expect the sample application to be posted?
2
0
2.2k
Jun ’19
Reply to Questions About Updating Older Core Data / iCloud App to Core Data / CloudKit
Once I have the path, I plan to do this.lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: “MyAppName”) // Create a store description for a CloudKit-backed local store let cloudStoreLocation = URL(fileURLWithPath: Original or Ubiquity Path) let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation) cloudStoreDescription.configuration = Cloud // Set the container options on the cloud store cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions( containerIdentifier: com.my.container) // Update the container's list of store descriptions container.persistentStoreDescriptions = [ cloudStoreDescription, ] // Load store container.loadPersistentStores { storeDescription, error in guard error == nil else { fatalError(Could not load persistent stores. (error!)) } } return container}()
Jun ’19
App with NSPersistentCloudKitContainer & Binary Data Attribute can't build
Trying to set up a test app using NSPersistentCloudKitContainer. Once I got the container set up, got error that attributes must be Optional or provide a default value, which makes sense. Problem is I have one Entity that has a Binary Data field. The field has been marked as Optional.However, the DataModelCompile build step complains that Photo.image must have a default value Also get a CloudKit Integration error along the same lines: Photo.image must have a default value.But there is no way to define a default value for a Binary Data attribute, so don't see a way to fulfill this.Anybody got a clue or do you think its just something I should Radar?
2
0
2.1k
Jun ’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:
Replies
Boosts
Views
Activity
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
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Aug ’19
Reply to NSPersistentCloudKitContainer not syncing existing data
You missed his point. Data entereed after setting up NSPersistentCloudKitContainer synced. It was pre-existing data which did not sync. For a person with a core data app who wants to use CloudKit, this problem is huge. And I'll bet that the original author signed up for remote notifications. It's not that he didn't get a notification, he didn't get the data.
Replies
Boosts
Views
Activity
Jul ’19
Reply to NSPersistentCloudKitContainer not syncing existing data
Just utilizing the container doesn't enable the sync. You have to add/request the capabilities throuigh your plist file (iCloud under capabilities, may require background too, but i'm unsure). Pretty sure you need remote notifications as well. I read on a blog somewhere a step by step to get it working, but I haven't found 'Official' instructions for anything more than the class declaration yet. I 'think' I googled NSPersistentCloudKitContainer and tutorial.. or maybe getting started.
Replies
Boosts
Views
Activity
Jul ’19
Reply to NSPersistentCloudKitContainer not syncing existing data
Update: Filed a feedback report since this seems to be an issue others are encountering as well. (See https://www.andrewcbancroft.com/blog/ios-development/data-persistence/nspersistentcloudkitcontainer-buggy-behavior-list/)
Replies
Boosts
Views
Activity
Jul ’19
Reply to Getting errors when trying to connect to CloudKit using NSPersistentCloudKitContainer
Besides being logged into iCloud, iCloud Drive needs to be activated in your device settings. NSPersistentCloudKitContainer always writes into the private database. Since the private database is somehow connected to iCloud Drive, iCloud Drive must be enabled in order to work.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’19
Reply to cloudkit sync not getting cloudkit updates
Apparently does not work on simulator only actual devices. See this from Andrew Bancroft https://www.andrewcbancroft.com/blog/ios-development/data-persistence/getting-started-with-nspersistentcloudkitcontainer/
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’19
Reply to NSPersistentCloudKitContainer for Shares
Agreed, I read the docs to mean that sharing is possible but I’m not able to use NSPersistentCloudKitContainer methods that return CKRecords based on managed objects at this time. I am hoping this is just due to early beta issues.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’19
Reply to NSPersistentCloudKitContainer can't get record from NSManagedObjectId
I'm currently facing the same issue (Also for fetching record IDs). As far as Apple stated here, this function can be used for creating shares, but I'm not sure if the NSPersistentCloudKitContainer is able to work with shared databases.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’19
Reply to NSPersistentCloudKitContainer for Shares
The presenter at WWDC 2019 (Nick Gillett) mentioned that Apple maintains a custom Zone in the private database (around 10:50 in the video).Since records get saved in the private database, I would think that CKShares and NSPersistentCloudKitContainer are a no-go combo.But, according to Apple's documentation, you can access the CKRecord for a specific managed object using dedicated methods, which will allow you to create CKShares: https://developer.apple.com... So I am confused.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’19
Reply to NSPersistentCloudKitContainer for Shares
I've been waiting on CloudKit + CoreData integration for a while, and I don't see how NSPersistentCloudKitContainer can't be used to share. Zero of my users has asked to sync the data between devices, everyone wants to share it between users, and how is such a core feature missing?Have to say, I'm not sure if it's missing because I can't find any documentation or tutorials, but it sure looks that way!
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’19
Posts Sample Application for 'Using Core Data with CloudKit'
The session Using Core Data with CloudKit (https://developer.apple.com/videos/play/wwdc2019/202/) spoke of a sample app for demonstrating the new NSPersistentCloudKitContainer and how it ties Core Data and CloudKit together. I didn't see it listed with the session resources; has it been uploaded somewhere else? If not, when can we expect the sample application to be posted?
Replies
2
Boosts
0
Views
2.2k
Activity
Jun ’19
Reply to Questions About Updating Older Core Data / iCloud App to Core Data / CloudKit
Once I have the path, I plan to do this.lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: “MyAppName”) // Create a store description for a CloudKit-backed local store let cloudStoreLocation = URL(fileURLWithPath: Original or Ubiquity Path) let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation) cloudStoreDescription.configuration = Cloud // Set the container options on the cloud store cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions( containerIdentifier: com.my.container) // Update the container's list of store descriptions container.persistentStoreDescriptions = [ cloudStoreDescription, ] // Load store container.loadPersistentStores { storeDescription, error in guard error == nil else { fatalError(Could not load persistent stores. (error!)) } } return container}()
Replies
Boosts
Views
Activity
Jun ’19
App with NSPersistentCloudKitContainer & Binary Data Attribute can't build
Trying to set up a test app using NSPersistentCloudKitContainer. Once I got the container set up, got error that attributes must be Optional or provide a default value, which makes sense. Problem is I have one Entity that has a Binary Data field. The field has been marked as Optional.However, the DataModelCompile build step complains that Photo.image must have a default value Also get a CloudKit Integration error along the same lines: Photo.image must have a default value.But there is no way to define a default value for a Binary Data attribute, so don't see a way to fulfill this.Anybody got a clue or do you think its just something I should Radar?
Replies
2
Boosts
0
Views
2.1k
Activity
Jun ’19