Data Persistence analysis
- plist file (attribute list)
- Preference (preference setting)
- Nskeyedarchiver (archive)
- SQLite 3
- CoreData
What do you do when you store large chunks of data?
You have many options, such as:
Use ' Nsuerdefaults '
Using XML, JSON, or plist
Using Nscoding Archive
Using a local SQL database similar to SQLite
Using Core Data
What is the problem with Nsuserdefaults? Although it is very nice and convenient, but it only applies to small data, such as some simple Boolean settings options, and then you need to consider other ways
What about this structured file of XML? Overall, you need to read the entire file into memory to parse it, which is very economical. Using sax is another tricky thing to do.
Nscoding? Unfortunately, it also needs to read and write files, so there are the above problems.
In this scenario, it is better to use SQLite or Core data. Using these techniques, you can load only the objects you need with specific query statements.
In terms of performance, SQLite and core data are very similar. Their difference is in the use of specific methods. Core data represents the graph model of an object, but SQLite is a DBMS. Apple generally recommends using core Data, but if you have a reason not to use it, then use the more basic SQLite.
If you use SQLite, you can use Fmdb (Https://github.com/ccgus/fmdb) This library to simplify the operation of SQLite, so you do not have to spend a lot of experience to understand SQLite C API.
iOS Development--Project Combat Summary & Data Persistence analysis