28th,march,2016
0 Preface
iOS Local data storage 5 ways:
1. nsuserdefaults preference settings;
2. plist archiving;
3. Nskeyedarchiver archive encryption;
4. SQLite3 embedded database;
5. Core data Object-type embedded database;
1 Nskeyedarchiver Archive
1.0 Introduction
This way features: Store all object types, encrypt storage, customizable objects.
The filing method is divided into: 1. Simple archiving stores objects directly as root objects; 2. Complex archives can store multiple objects and set corresponding key;3. Custom Object Archiving
1.1 Simple Storage
1). Archive ("serialization"):
2). Access ("deserialization"):
1.2 Complex storage
1). Archive:
Tip1:writetofile atomically useauxiliaryfile: The word "use auxiliary files" means to translate. Atomically will naturally associate with the meaning of atomicity. Reference 3 mentions that this parameter indicates the atomicity of the write file, and yes indicates that a secondary file is created first until the data is successfully written and then imported into the destination file to guarantee the atomicity of the file.
where encode .... You can store data types in:
2). solution file:
1.3 Custom Object Storage
Custom objects need to follow the Nscoding protocol, which has two methods to implement:
1) Custom objects:
2) Custom Object Archiving && unpacking
2 references
1). iOS Development Series-OBJECTIVE-C Foundation framework
2). Summary of IOS Archive (archive) //Get from small white
3). WriteToFile atomically parameter interpretation of NSString in Objective-c
iOS Local Storage 1--nskeyedarchiever archive