I created a simple Notes app based on Core data. Now i want add sync between user devices.
And all articles that i read (this, this) said that i should fully get rid of my core data database, and all my code will lost and rework all with ICloud kit?
The is no way to sync data from Core Data to ICloud ? And if i get rid of core data, how my app will work offline ?
And please suggest good simple projects with ICloud sync
P.S. I googled about an hour. Icloud is deprecated so do sync with it is not recommended. I confused. How now i can sync data between devices??
Core Data used to have iCloud syncing, but it has been deprecated as of iOS 10. It had several problems, sometimes major.
Apple now has something called CloudKit, which is not the same thing. You can use CloudKit to sync data between devices. But this does not mean that you should drop Core Data. CloudKit only syncs; it is not a replacement for having your app save data on the device, it's only a way to send data to other devices. If you're using CloudKit, you also need to use some other way to store data on the local device.
Also, it's "CloudKit". Not "ICloud Kit". I don't know why, but it's important to get the names right.
Related
I'm developing iOS app which is using CloudKit. I'm pretty clear how to download/upload data from cloud when requested on the device. It works just fine when internet connection is present. I'm thinking to allow users to access their data offline also. After brief research I discovered that CoreData integration with iCloud was depreciated as of recent Xcode release. I found some third party pods on github which let you handle this problem by syncing core data from device to iCloud. I'm a bit skeptical using those plugins due to possible data loss or other issues. Is the idea behind depreciating CloudKit to move away from offline storage? Im thinking now what to do... should I attempt to create some sort of sync between core data and iCloud or not use core data at all and just let users to access data only when online connection available. Such approach would save device storage but restrict data access to online only. Any recommendations ?
CoreData integration with iCloud is not depreciated, here are some references from Apple:
Setting up core data with CloudKit
Syncing a core data store with CloudKit
Mirroring a core data store with CloudKit
WWDC 2019 - Using Core Data With CloudKit
I am trying to develop a watchOS 2 app to go along with my iOS app. The iOS app utilizes Core Data, and the Apple Watch app is simply going to be a "read only" client and display the data from the iOS app.
I have read a few things regarding managing two data stores, but that seems to be overkill. I just want to transfer the data to the watch app on launch then send background transfer if things change on the phone.
My question is how do I send this information to the watch app initially? I don't think I can send the actual data objects to the watch app. Do I need to convert the objects to a dictionary and send all of the relevant information via the WatchConnectivity API?
Your approach sounds good. Mirroring your CoreData database on your watch app would indeed be overkill if you don't play to change the data on the watch.
So using the Application Context to send the data via background transfer is the right choice. This has only one caveat: The updateApplicationContext method that you use to tranfer the data only accepts a dictionary of property list values. In other words, you can only send objects that you could add to a property list:
Array
Dictionary
String
Data (NSData)
Date (NSDate)
Integer
Floating-point value
Boolean
So, you'll have to convert your Core Data objects to dictionaries that contain only those types, before you can send them.
That's a bit of an effort, but you would have to do that anyway even if you wanted to mirror your database on the watch side, because with watchOS2 you cannot use App Groups anymore to share CoreData files.
Mine is a background application. There are thousands of data that are stored in local storage and till now i've been syncing the data to a remote server using http post. I want to know whether it is possible for me to use iCloud to sync my core data and then is it possible to sync from iClod to a remote server. I just want to use iCloud for storage purpose. I meant can it be operated like Parse and other third party cloud servers. I'm stuck with this. Any help would be greatly appreciated.
The only thing iCloud with Core Data does for you is sync data between multiple devices that use the same iCloud account.
I want to know whether it is possible for me to use iCloud to sync my core data...
Sync from one device to another, yes.
...and then is it possible to sync from iClod to a remote server.
If you're using Core Data with iCloud, you're still using Core Data, so any server sync you're doing now with Core Data will continue to work in the same way.
I just want to use iCloud for storage purpose.
It does store the user's data on the iCloud service, though it can only be accessed through your app.
I meant can it be operated like Parse and other third party cloud servers.
It depends on what Parse (or other third party) services you're interested in. Parse does more than iCloud, it's not really the same thing. If you would use Parse only to sync data between different devices, you could probably use iCloud. If you would use Parse in any other way at all, iCloud is not a replacement.
I have db which is kept in Core Data and I need to download full data from some storage. I don't want to write web server for this. Is there any way to store my full data for further downloading? Can I use iCloud for this? Or anything else? Thank you
iCloud is connected to you personal Apple ID, so it would not be possible (or at least not its intended use) to allow others to download data from your iCloud account.
Have a look at Parse or Azure. One of them might be the solution you are looking for.
With iCloud, you can sync your CoreData databases across multiple devices. This works by means of SQLite creating a transaction log that is replicated via the cloud. I like that mechanism, by I don't want to tie it to iCloud and Apple's servers.
Is there a way to enable this transaction log and manually replicate it using custom code and servers under my control?
No, at the moment the transaction logs are not exposed by any API. You can look at them on your Mac if you have iCloud enabled (they live in ~/Library/Mobile Documents/) to try to figure out how Apple is doing this and replicate it yourself. Sounds like a very difficult problem though.