0

I currently have a CoreData based App on the App Store that supports iCloud with both iOS and OS X devices. It is a "semi-document" based app; that's to say it's technically not a document based app but it manages multiple Core Data databases.

I've done this by creating my own class that manages a list of database names (e.g. Shopping/ToDo/e.t.c) and a system of instantiating multiple NSManagedObjectContexts based on these database names, using iCloud enabled NSPersistentStoreCoordinators.

I'd like to update the App soon (i.e. version 2) and have been reading about UIManagedDocument and NSPersistentDocument but this has caught my eye:

Note: In OS X, the NSPersistentDocument class does not support iCloud.

My question is: Is it possible to subclass NSPersistentDocument or set up a system whereby CoreData, iCloud and iOS and OS X can come together in a document based app?

Rob Sanders
  • 5,197
  • 3
  • 31
  • 58
  • I would avoid UIManagedDocument and NSPersistentDocument. However have you considered using a single database instance for containing all your lists by using a category. That way you have multiple list types all residing in a single Core Data store and you only have to synchronise one store. For the user is remains transparent. Much easier to backup and restore all the users data as well. – Duncan Groenewald May 13 '15 at 00:32
  • The lists in the question are just examples, in reality my object graph is quite complex. I organise data bases by year (e.g. 2015, 2016 e.t.c) so I could just have a year attribute for all objects in the data base which would then allow me to use just the one database. Would this be beneficial and better than my current method? – Rob Sanders May 13 '15 at 15:21
  • Well it obviously depends on the full set of application requirements but it would largely eliminate the file management requirement so you would only have to deal with a single Core Data database on each device. Bearing in mind that unless your app actually opens each store on the device data won't be replicated. Having a single store means that no matter which 'year' the user might have made edits in these edits will be replicated to other devices. Having multiple stores means doing upgrades becomes more complicated as well. – Duncan Groenewald May 14 '15 at 02:05
  • You don't want to use NSPersistentDocument look on GitHub for BSManagedDocument, it is a much better place to start. I am working on a version of UIManagedDocument that will play nicer with iCloud and them I'll be working on an OS X version that works with iCloud, it will be open sourced if you would like to contribute in any way. It's all being written in Swift if that matters. – theMikeSwan Oct 27 '15 at 00:44
  • Thanks for the tip. I'll definitely check it out. – Rob Sanders Oct 27 '15 at 08:06

0 Answers0