Archiving, in other languages called "serialization", is to save the object to the hard disk, the solution, in other languages called "deserialization" is to restore the hard disk files to objects. In fact, archiving is the process of data storage, there are five ways to store data in iOS:
XML attribute list (plist archive)
Nsuserdefaults (preference setting)
Nskeyedarchiver Archive (encrypted form)
SQLite3 (embedded database)
Core Data (embedded database for object-oriented approach)
First, let's take a look at the XML attribute list, the XML attribute list is archived by storing objects in a plist file, which is relatively simple to do, in fact, equivalent to XML serialization. But at the same time it also has shortcomings: first, this method is clear-text preservation, and the other is that the object of operation is limited, only Nsarray, Nsmutablearray, Nsdictionary, Nsmutabledictionary support (as long as the corresponding WriteToFile method is called when archiving, the solution calls Arraywithcontentsoffile or Dictionarywithcontentsoffile, Note that, like NSString, NSNumber, NSData even if this method is stored, it is not in XML format.
Second, if you want to archive for more objects or to be able to encrypt when you need to archive, you need to use Nskeyedarchiver for archiving and file, the scope of this method of archiving is more extensive and archived content is ciphertext storage. From the archive scope Nskeyedarchiver is suitable for all OBJC objects, but we need to implement the Nscoding protocol for custom objects, and from the archiving approach Nskeyedarchiver is divided into simple archives and complex object archives, A simple archive is a single object that can be directly used as a root object (without setting a key), a complex object is targeted at multiple objects, and different objects need to be set to different keys when stored.
If ported to iOS apps, change Nsarchiver and Nsunarchiver to Nskeyedarchiver and Nskeyedunarchiver. While the foundation section iOS and OS X are designed to be as generic as possible, there are subtle differences.
About archiving for iOS