iphone Development Data Persistence Summary (end)-Comparison of 5 data persistence methods Iphoneiphoneiphoneiphoneiphone Data Persistence comparison summary
This article is a simple comparison of 5 data persistence methods commonly used in iOS
1th: Userdefaults (iphone development "20" data persistence summary of the 1th article-nsuserdefaults)
1) Strong usability
2) data is stored in the. plist file
3) Generally save configuration information, preference information, cache data, etc., for storing a small amount of data
4) Cons: Unable to serialize custom object to property list
2nd: attribute list (iphone development "21" Data persistence Summary of 2nd-Properties file (. plist))
1) strong ease of use
2) data is stored in the. plist file
3) typically used for storing small amounts of data, nor for handling large amounts of data
4) Cons: Unable to serialize custom object to property list
This method is very similar to the 1th kind, the preference information, the cache data and so on generally uses the 1th kind, other situation generally uses the second method.
3rd: Archive (iphone development "22" data Persistence Summary of the 3rd-archive (Nskeyedarchiver, nskeyedunarchiver))
1) strong ease of use
2) data stored in archive file
3) typically used for storing small amounts of data
4) The biggest advantage is that complex objects can be written to the file can be archived collection classes, so no matter how many objects are added, the way the object is written to disk is the same, does not increase the workload;
If you cannot save complex objects with the property list of the 2nd method, the workload will increase with the object
4th:sqlite3 (iphone development "24" data persistence Summary of the 4th article-sqlite3 database)
1) IOS-related APIs are C-language interface, and the design of the ease of use is not strong
2) The data is stored in the. DB3 (or sqlite3) database,
3) can store a large amount of data, storage, retrieval of large amounts of data is very efficient;
Open source embedded database, acid transaction,
A complex aggregation of data can be much more efficient than using objects to perform these operations.
Lightweight, cross-platform, resource-intensive, no network server, only database-level locking, no user account concept.
The SQLite API does not differentiate whether the current operation of the database is in memory or in the file.
Disadvantages:
1. Locking mechanism for concurrent access
SQLite's performance in concurrent (including multi-process and multi-threaded) reading and writing is not ideal. The database may be exclusive to write operations, which can cause other read and write operations to block or error;
2. SQL standard Support not complete
If the foreign key is not supported about the bundle;
PS: Two commonly used frameworks for encapsulating sqlite3 operations Bnrpersistence
Fmdb (More object-oriented, eliminate the hassle of redundant C code, more lightweight than coredata, provide multi-threaded secure database operations, effectively prevent database clutter)
Three core classes: Fmdatabase: An object represents a separate database
Fmresultset: The result set after query
Fmdatebasequeue: Thread-safe execution of multiple queries or updates
Disadvantage: Multithreading does not support simultaneous use of the same database connection operation.
5th: Coredata (iphone development "26" data persistence Summary of the 5th article-coredata technology)
Similar to hibernate in Java
1) personal sense of ease of use is not strong
2) data storage can be selected Sqlite,xml,plist or otherwise as a persistence scheme, using SQLite generally
3) Advantages: the implementation of functions including Redo,undo, data validation, etc.
iphone Development Data Persistence Summary (end)-Comparison of 5 data persistence methods