iOS Local Storage 1--nskeyedarchiever archive

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.