4
votes

I'm trying to choose the best aproach for my CoreData App with support to iCloud.

I think a good strategie whould be creating a SingleTon class to handle all the CoreData and iCloud stuff and delivery a ManagedObjectContext to the App.

This class should handle the case of the user change his iCloud account or the case of iCloud be disabled. To do this I need to work with multiple NSPesistentStores, one for iCloud and one for the case of iCloud not be available, and migrate data between then when needed. right?

My main question is, what are the pro and cons of using a UIManagedDocument Class or the traditional CoreData Stack to create a singleton class witch handles the CoreData/iCloud basic logic of an App???

The code sample from the WWDC 2012 whould also work with an UIManagedDocument insted of the CoreData normal stack?

1

1 Answers

3
votes

Use whichever fits better in your application... it's pretty much up to you. Generally, though, UIManagedDocument works better for apps which are document-centric (like Apple's iWork apps) and using the Core Data stack directly works better for apps which aren't.

The sample code from WWDC 2012 session 227 fits your singleton idea better -- I'm not sure it'll be of help if you're using UIManagedDocument, as that class manages its own Core Data stack.