views:

372

answers:

2

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.

+4  A: 

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!

h4xxr
Definitely second this. CoreData is kind of confusing at first, however after you get used to it, it works very nicely and clearly, and performance is excellent. It mostly abstracts the database away from you (which was a major plus for me). I suggest going with CoreData if you can.
jbrennan
ok I'll go with CoreData. And I'm unsure how many words, it all depends on how the user uses it. If I were to make a guess I would say the average would be around 300 words (per document)
Matt S.
does anybody have a link to a good guide on how to use coredata?
Matt S.
+1  A: 

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.

itsaboutcode
achieving methods?...
h4xxr
Sorry i mean archiving methods.
itsaboutcode
@mattCheck out the following tutorial on Core Data.http://cocoadevcentral.com/articles/000085.php
itsaboutcode
There's no/hardly any code?!?!?!?! Holy crap that's awesome!!!
Matt S.
do you have a link to another guide? That one doesn't seem to help me all that much
Matt S.
I found this the best one.http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/There you can also check out following linkshttp://blip.tv/file/2279503http://developer.apple.com/macosx/coredata.htmlhttp://rentzsch.com/links/adcCoreDataVideoTutorial
itsaboutcode
Forget to point that blip.tv/file/2279503 is not in english.
itsaboutcode
uh, what about an iphone one, the NSArrayController mentioned in the first guide and the video (the english one) isn't there, and the other ones don't work well for me
Matt S.