iCloud Core Data 2018 - ios

I have an iOS application written in Swift with Xcode 9 that stores objects locally with Core Data. I would now like to apply iCloud sync to this app such that a single user can access and modify this data across multiple devices, though I am not sure where to begin. I have searched much but it remains unclear to me if "iCloud CoreData" works anymore or if CloudKit is ideal.
What would be the best approach to this today? Could someone perhaps direct me to a modern example/documentation? Any help would be appreciated.

Related

Xcode 8/Swift 3: make API information available offline? [duplicate]

This question already has an answer here:
How to make offline database for my app?
(1 answer)
Closed 6 years ago.
I'm currently working on an application in Xcode 8/Swift 3 which runs through APIs. Essentially, I'm parsing information using SwiftyJSON from my MySQL database which keeps the content current and easily updated.
To keep it so the content is also available offline, I'd like to introduce a facility where the data is downloaded and stored on the phone so it is available in "offline mode".
I know it's a completely open question but can anyone point me in the correct direction of how I could make this JSON information available offline? I've tried searching the net with no success.
I know it's not Swift, but the absolute master of this has recently open sauced his master piece: Dash for iOS.
Reviewing what he's done to get rapid scrolling and searches might give some deep insight into how to best do this as done by someone with (arguably) more experience in this area than anyone other than Apple:
https://github.com/Kapeli/Dash-iOS
I will prefer here 2 option either I will go with 1.SQLite DB or 2. NSURLCache
For SQLite DB you can use FMDB wrapper-https://github.com/ccgus/fmdb
For NSURLCache check this link Best way to Cache JSON from API in SWIFT?
If you just want to save json then go with NSURLCache for offline mode.
Achieving offline for iOS is having two best paths they are CoreData and SQLITE. As per the definition of CoreData suggests it is a Model layer of the project. It comes with less efforts on developer side. Bit contrast SQLITE having the same way but little efforts on it.
In my project we are using the CoreData for offline maintenance. Really we have few concerns on the Relational data fetching, Although there is a Predicates representing CoreData for the same still it is limited to some part. These type of situations SQLITE is really a life saver. We can easily fetch the records with simple JOIN commands.
Conclusion:
If you have more complex data relations it's really better to go with the SQLITE, Apart from CoreData is best choice.

Developing Quiz App - Data Storage iOS

I am planning to develop a quiz app in iOS and doing it offline. I need to store 100s of questions and options in that app. How to store? How does core data comes in handy here? Is there any other good methods for this problem?
The app is meant to be offline.
You can also use SQLite database for saving Questions and Answers offline for your Quiz app. You can create tables in SQLite and save and fetch data from that using SQLite queries.
I would recommend you to use realm.io. It measures better than core data, its fast and simple to use. On https://realm.io there is lots of documentation.
I find realm much easier to set up and in generally to comprehend. It works nicely with SwiftJSON and hence in my view much easier to connect to backend.
Preloading core data can be quite cumbersome and to me it seems that core data still relies heavily on objective c.
On the other Core Data is made by Apple so it could be more stable solution on longer run (parse.com)

Synchronise Realm data between devices

I have been searching around the internet, but without finding a solution.
Is it possible to synchronise the realm data between more devices? Lets take an example, if the user use the application on both iPhone and iPad.
How can i make the data synchronise? I have been looking into CloudKit, but it doesn't seems like it works together with Realm (Correct me if i'm wrong).
Any suggestions? I want the data to be synchronised, and i want a backup of the data - So the user can delete the app, and still get the data down.
Realm now offers two-way synchronization using their own Realm Object Server, as part of the Realm Mobile Platform: https://realm.io/products/realm-mobile-platform/
EDIT: The Realm Mobile Platform is available (in beta as I edit my answer) so this kind of sync is possible. My previous answer was in an older context, with this technology unavailable.
Previous answer: It's not possible. The binary format for the Realm database on the device is not synced on any service like iCloud or Google Drive efficiently.
The long answer can be found in my previous answer here.
So, I think the best way for doing so is through an API.
Another alternative -> You can try this swift framework to sync Realm database with CloudKit ice cream
I think the Document folder is synchronise through iCloud

Core Data iCloud sync or smth else?

I build an iOS app which works with base. User can work with it everywhere, that is cool. When application starts for the first time, obviously, base will be empty. For now, user's base stores data locally with Core Data. But there is a case, when user may have his own base with a lot of data and he do not want to start work from scratch. For this reason I want to create simple Cocoa App for macOS, which will allow user to import some data from, for example - CSV file.
Both Core Data models (iOS app and macOS app) will be the same. I just want to make sync between two platforms.
I think it's possible with cloudKit, but which way is the best? Core Data Sync or smth like supporting MySQL database on server, etc...
Thanks in advance!
Asking which method is "best" is a matter of opinion, but in mine, Apple has made working with iCloud fairly simple. If all you want to do is sync between platforms, I would use cloudKit. There seems to be no reason to spin up your own MYSQL database instance and introduce another level of complexity, when the functionality you're looking for is free and easily accessible.
See this WWDC16 video for some cloudKit tips: https://developer.apple.com/videos/play/wwdc2016/226/

iOS 7: What happened to UIDocument / UIManagedDocument and iCloud?

I was taking a look at WWDC 2013 sessions concerning iCloud and Core Data. I was really hoping to see there any new videos for UIManagedDocument or UIDocument. You might remember that those classes theoretically offer a great and simple approach to save data with (UIManagedDocument) or without CoreData (UIDocument) locally and in iCloud. But there have been or still are some really annoying system-based bugs coming along with those concepts, especially when syncing data between devices, see for example here.
However, there was NO video covering the UIManagedDocument/UIDocument and iCloud topic. The video "What's new in Core Data and iCloud?" just covers the classic approach for using Core Data persistent stores which is extended by new API to automatically cover fallback stores and syncing. Has anyone information what happened to UIManagedDocument/UIDocument? Did they give it up and see the classical approach as the better way to have apps with Core Data and iCloud sync?
My understanding is that UIManagedDocument is a lightweight wrapper over core-data to abstract away some of the common core data setup and interactions. It is also a way to package other 'document' elements but managing the iCloud syncing of those items is left as an exercise for the developer.
If you are using iCloud, UIManagedDocument does not support “additional content” in the document directory (see additionalContentForURL:error: and related methods)
That's referenced from: UIManagedDocument
See Also: additionalContentForURL:error:
Pretty much anything that applies to core data applies to UIManagedDocument where it uses core data under the hood. For example I make use of the new fallback stores in my APManagedDocument project.
What kinds of things were you hoping to see added in iOS 7?

Resources