开发者

Is it better to store data in plist or Sqlite database? [duplicate]

This question already has answers here: plist or sqlite (2 answers) Closed 8 years ago.

In my iPhone app, I have large amount of data i.e. around 1000 pages of text.

Where should I do to store them?

Should I use plist or Sqlite Database table?

Which of them would prove to be more efficient?

Please Help and Suggest.

Than开发者_开发技巧ks in Advance.


For big amount of data, sqlite or coreData are better because all data are not load in memory to access to one.
With pList, entire file is read in memory. After, you can retain only data what you want, but it is not optimized.


Depends on how and for what you want to store the data:

Use SQLite if:

  1. Data needs to be accessed only partially
  2. Repeated updates
  3. Data itself is large in terms of bytes

Use plist otherwise!!

In your case, I would reccomend, using SQLite 3 or coredata.


You should use a plist for storing configuration settings.

For what you're doing I'd use sqlite3 or core data storage.


pList is really just an xml file so the advantages (such is both easily readable by human and computer) and disadvantages of xml (efficiency of storage/retrieval) apply.

While SQLite gives you the benefit of SQL obviously. For large data SQLite would be the better choice


What's important is the way you'll be accessing them. If it's something you access randomly or in small portions, you'd use a database like sqlite. If it's something you are using all of rougly at once, a plist is fine. As @Benoît mentioned, plists are loaded into memory completely. For something like a book you might also consider storing pages in separate files, thereby using the file system to manage access (depending on how you intend to use it of course).


Property Lists

A plist is simply a list of nested key-value pairs which can contain common data types like Strings, Numbers, Arrays and Dictionaries.

Pros

  • Simple to understand.
  • Easy to work with.

Cons

Cannot run complex queries on them (at least not easily). You have to read the entire file into memory to get any data out of it and save the entire file to modify anything in it.

SQLite

Until CoreData came along, this was the popular way to read and write data in iPhone applications. If your a web developer, this ain’t nothing new.

Pros

  • Unlike plists, you don’t have to load the whole database up front. This makes SQLite more suitable for applications with lots of data.
  • Better than plists for slicing and dicing data.

Cons

Steeper learning curve than plists. Can get tedious to work with.

Core Data

Its new, its exciting, and its probably what most developers will use from here on out.

I have not spent enough time with CoreData to summarize it; check out the tutorials (below) to learn more about it.

Pros

  • Nearly all the benefits of SQLite with a lot less hassle (Apple does a lot of the dirty work for you).

  • As Apple’s preferred method it has a lot more official documentation and sample code (it seems the articles and sample code for the other two methods have mysteriously disappeared from Apple’s website).

Cons

  • Steeper learning curve than plists.
  • Killer: only works on iPhone OS >3.0. Its killer if your market consists largely of iPod Touch users (who have to pay for upgrades).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜