Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreData and iCloud

I am developing a core data application and was thinking of adding iCloud support, but after looking around on the web I frequently heard that iCloud+CoreData is unreliable and will often break.

Is this true? A book I am reading on the subject of core data mentions that iCloud+CoreData was unreliable in iOS 5 but has since been fixed, however I have also heard the opposite, that iCloud+CoreData is still unreliable in iOS 6. If so would storing the database in a custom format help at all?

like image 344
john smith Avatar asked Jun 12 '13 12:06

john smith


People also ask

Is Core Data a cloud?

Use Core Data with CloudKit to give users seamless access to the data in your app across all their devices. Core Data with CloudKit combines the benefits of local persistence with cloud backup and distribution. Core Data provides powerful object graph management features for developing an app with structured data.

Should I use Core Data?

The next time you need to store data, you should have a better idea of your options. Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.

Where does Core Data store data?

The persistent store should be located in the AppData > Library > Application Support directory. In this example you should see a SQLite database with extension . sqlite. It is possible that you don't see the persistent store in the Application Support directory.


2 Answers

Now that iOS 7 has been released, we can talk about it. And everything would seem to indicate that in iOS 7 iCloud Core Data sync has been fixed. I'm about to add iCloud Core Data sync to an (iOS 7 only) app I'm building, so I can't yet speak from personal experience, but everything I've heard suggests that it's now good for prime time.

I highly recommend watching the "What's New in Core Data and iCloud" session video from WWDC 2013: https://developer.apple.com/videos/wwdc/2013/?id=207 (requires an Apple Developer Program membership). I've watched it twice now, and they've certainly made things a lot more straightforward.

Lastly, I recommend taking a look at UbiquityStoreManager on GitHub. It's a library that pretty much does all the painful parts of iCloud Core Data for you. It's been modified to take into account the significant improvements in iOS 7, all though if you want to take advantage of them your app has to be iOS 7 only (that applies whether you use the library or not).

UPDATE: Since posting this answer, I now can speak from personal experience, and can confirm that Core Data iCloud Sync in iOS 7 is rock solid, and what's more, unbelievably easy to implement. I added it to my app without using UbiquityStoreManager or any other 3rd party library and it was very straightforward. Literally just a few lines of code.

EDIT: I created a GitHub repo with my iCloud Core Data stack for iOS 7. Hope it helps: https://github.com/mluisbrown/iCloudCoreDataStack

like image 83
mluisbrown Avatar answered Sep 20 '22 01:09

mluisbrown


It seems that the video/link (https://developer.apple.com/videos/wwdc/2013/?id=207) mentioned by @mluisbrown is no longer available.

There is a newer version as of 2021: https://developer.apple.com/videos/play/wwdc2021/10015/

like image 30
HeyMan Avatar answered Sep 18 '22 01:09

HeyMan