Question

I want to save large amounts of text then display them (first in table view, then in text view), however I am unsure which method to do it in. Should I use SQLite, or one of the archiving methods.

Was it helpful?

Solution

Your statement of "large amounts of text" is ambiguous. You could mean any of the following:

  • A large set (eg 10,000 items) of small text (eg 30 words) items
  • A small set (eg 50 items) of large text (eg 3,000 words) items
  • A large set of large text items...

I'll try and answer for each of those scenarios.

If you're storing a large number of records, I find a database is always a good idea. This means using either SQLite or CoreData. CoreData is a bit more work to get going but there are plenty of examples around and this approach will pay off in the long run.

The main reason a database is required for large sets of data is that you then don't need to load it all at once. You don't want your users sitting around for 30 seconds while your app loads up all its records (even assuming it will all be able to load into memory - it goes quickly!). CoreData in particular is designed to work with this "load just the data the user needs to see" model.

However if you have a small set of data, even if each item is relatively large, you're unlikely to gain much by putting them into a database. If you think the quantity of data could grow in the future, it's worth doing it. But if it's likely to never grow you can probably get away with archiving - and possibly even the easiest of all the mechanisms, sticking an array or dictionary straight into a plist. This is the quickest way to implement but as described above certainly is a bad idea in a number of situations.

Hope that helps!

OTHER TIPS

I would say if your text/data is just few kilo bytes, then go for archiving methods, otherwise sqlite is there for you. Good luck.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top