How to persist data on iOS systems, Cocoa provides 4 mechanisms:
1 nsuserdefaults
It is used primarily to store short information, such as application settings and attributes, and user data.
2 List of properties
Store the data on disk as a list. The property list classes include Nsarray, Nsdictionary, NSString, NSNumber, NSDate, NSData.
These types of data can be directly called WriteToFile and the corresponding load function to be stored to disk and read out from disk.
The corresponding load functions are:
Arraywithcontentsoffile:
Dictionarywithcontentsoffile:
Stringwithcontentsoffile:
Datawithcontentsoffile:
NSDate and NSNumber can be stored after replacing with NSString.
3 Object Archiving
For those data that cannot be simply represented by a property list, the object archive is used to store it.
By using nscopying and implementing the two functions Encodewithcoder and initwithcoder, it is possible to replace such objects with
NSData, then use the 2nd method to store and read.
4 CoreData
A persistent tool provided by Apple. Using this method is, first we have to build a data model, and then we can easily
The storage and reading of the object, the other all to a system.
iOS Persistent storage