can core data be used with cloud kit/document storage?

since importing changes takes for every, and throws errors I don't understand (which aren't thrown when using a local store for the same operations), I was wondering if I can use cloud kit or document storage with core data.


the plan is to either provide a seemless sync of data between two devices by mapping the coredata model objects to cloudkit records or simple drop the sync plan completely and use icloud to just back up the store file on a daily basis using document storage.


i was wondering if either of the two could be use.


as far as my app goes, very few users would want to use the app from two devices so just having a cloud back of the store file from a single device is also enough.


please let me know if either can be done?

Using Cloud Kit for the storage side of an NSIncrementalStore wouldn't really work, because Cloud Kit defines itself as producing incremental search results.


Just leaving your persistent store file in a place where "end user iCloud" is going to see it, back it up, and mirror it between devices as collection of monolithic files runs into the problem that "end user iCloud" is going to back up and mirror the whole file even if you just add or change fifty bytes in the middle. So everything gets incrementally worse as your datastore gets bigger; and that's why all the effort was spent trying to get the 'incremental changes' model for CoreData using iCloud to work.

You got me slightly wrong over here. Let my store be local and not in a ubiquity container. Every new entry in the store will have a unique identifier. When a new entry is added to the store, the managed objects are synced between devices as records in the cloudkit key value dictionary. Then on another peer, they are inserted into the context and saved all over again in the store local to that devices. When an entry is deleted from a devices the unique identifier is synced over to the other peers and marked for deletion and then the code on the other peer finds the primary entity matching the identifier and follows the delete logic on the other peer (deleting the primary entiriy, setting its relationship end entity pointer to nil and if this was the last primairy entity object in the relaitonship end object's NSSet, delete it as well) In case of editing the primary entity i simply delete the old entry and add a new one to avoid writing a separate logic for changed relationships. Basically my problem in core data with icloud is that its throwing valadition errors for non optional relationships when importing after deleting entries from one peer which are never thrown for the same object when the store is local! And since the latency is so high that sometimes i have to wait an hour before changes are imported (maybe something wrong with Apple's India servers) i cant practically debug my app. I know using cloudkit sounds very impractical so i have a fall back plan. Using icloud document storage to back the store file periodically or manually by the user. . Providing sync is not a very critical feature of my app.

And i have no clue where the paragraph and new line separators disappeared from the above post.

If you think "Core Data with iCloud" is bad, you're going to run into worse if you try to implement the scheme you describe in the first part of your post.


Cloud Kit fundamentally produces increment results. Your code for processing those incremental results is going to produce the same sort of impossible exceptions that you're complaining that Core Data with iCloud is throwing. Because those are the sorts of errors that occur when you validate incremental change sets sent arbitrarily across networks.

implementing core data with icloud is very simple. degbugging it with the current state of icloud is a pain.


lets drop the idea of cloudkit


what about document storage to backup the store.

"Cloud Kit fundamentally produces increment results. Your code for processing those incremental results is going to produce the same sort of impossible exceptions that you're complaining that Core Data with iCloud is throwing. Because those are the sorts of errors that occur when you validate incremental change sets sent arbitrarily across networks."


Not sure about this assertion. If you can use Core Data to sync with other types of web services, why not CloudKit? Core Data can act like a cache in this case. When you save objects to CloudKit, you can also add them to your ManagedObjectContext ... and save the context if you get a confirmation, and persist the refereceID as well, so you can retrieve that object from CloudKit later on.


I haven't done this myself, but I am intrigued to know why you think it's technically not possible.

I believe your question was to NotMyName. In anycase I find cloudkit confusing so wanna avoid that as much as possible. Its sad that cd with icloud has been avaialbel for so long and apple hasnt fixed the most fundamental aspect of its working, over the years! So here I am, a first time developer on my debut project, and i have learnt and ser up everything but cant test it (let alone ship it) cause of the problems. Like i said, the valaidation errors of non optional relationships being nil after deletinng a record happens only when importing changes to another peer. When i use the local store (without icloud) these exceptions arent thrown.

can core data be used with cloud kit/document storage?
 
 
Q