How to store large ordered data?

For a very small application with little data, should I use CoreData or just store the data in the Documents directory?

  • I am looking at starting my first application, which will be my entry into the App development and will be used more for experience than anything else. The app has a simple premise; the ability to record some information about how much you owe and how much people owe you. So the data itself will simply be a TableViewController of a list of people you owe and people who owe you in a different tab, etc. Each entry will have the name, amount, currency and notes. So not a huge amount of data at all. With this in mind, should I use CoreData or should I just store the data in the documents directory, as it's never actually going to be THAT many entries. But I would of course like it to scale as well. The actual app itself will have a few UI changes from the default, but that's it, no sounds (for now), etc. It's going to primarily be an iPhone app but i would like to eventually build an iPad app for it as well and have the data sync; I'm guessing this would be through CoreData and iCloud? Any thoughts on this would be massively appreciated; I just need to know which sort of data handling technique would actually be better. Thanks,

  • Answer:

    If this is your first application, I would avoid CoreData. It's a dazzlingly complex framework and your use case wouldn't benefit much from it. Would be more worth your time to just serialize your objects using JSON (or another format) to files, like you said. You could also use something like https://parse.com/ or https://www.dropbox.com/developers/blog/26 to access data across devices. iCloud syncing can also be used without CoreData, depending on how you want to handle file version conflicts.

Clay Allsopp at Quora Visit the source

Was this solution helpful to you?

Other answers

It really depends on your overall comfort level with programming and how quickly you find yourself picking up iOS development. If you're feeling confident I'd recommend giving Core Data a go -- your use case seems pretty simple -- and if you find Core Data to be too complex or you're having problems, you can always abandon ship and use a plist or JSON. (One other thing to consider is that Core Data iCloud sync is, as of iOS 6, quite broken.)

Colin Barrett

Unless your application is more complex,, I think the best solution is to simply use the NSCoding protocol. Just add a encodeWithCoder / initWithDecoder methods to your main objects and your app can write its data to a file at any point. (And restart by reconstructing the prior state). It's very fast and just works.

Glyn Williams

Go for it. It's worth using Core Data at some point and this is a pretty easy use case. You can set up a Managed Object model file with a single entity, then use that to generate the corresponding NSManagedObject subclass. In your table view, you can use an NSFetchedResults controller to load up the people on a per tab basis. There's not really going to be a "better" way to handle data your app. As for iCloud - iCloud + CoreData is, as talked about by many, a bag of hurt right now. By the time you ship your app though, and are ready to make updates? Who knows. Also, you can use Core Data with any web backend you wish, choosing CoreData now doesn't lock you into anything. And of course, if you want to move away from CoreData at some point, you can always change it.

Brian Papa

I also say go with Core Data now. That the app is small and simple should be an incentive to do so. Better now than when it is a large and complex app. The few hours extra you have to spend will be given back to you in convenience when dealing with persistence and hooking it up to the UI. Saving your data to iCloud is also a one liner with Core Data. There is lots of help and wrappers out there to deal with the problematic stuff down the line. Put simply, solve the problems you have right now with the highest abstraction possible, when you have a million customers and they all scream for an iPad syncing version - you will have the time and means to solve that.

Ricki Vester Gregersen

I find out http://Parse.com is pretty easy to use to sync your data without local storage, you even don't need any thing like CoreData, Sqlite or plist. If you want to store your local copy and cache the data. CoreData is actually very good. Also MagicalRecord is the best mate to work with CoreData.

Jake Lin

I would suggest using CoreData for storing this info. As you mentioned, if you want to build an iPad app in the future which syncs this data, you will need iCloud integration (unless you decide to have a server setup). CoreData sync with iCloud is hassle-free compared to syncing data from Documents (esp incremental sync). The CoreData structure itself won't be very difficult to setup for the app that you are describing.

Lata Sadhwani

Go for coredata using MagicalRecord. Its even simpler than doibg json serialization...

Mikkel Bruun

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.