Ios persistent Storage

Source: Internet
Author: User

Cocoa provides four mechanisms to store data persistently on iOS:
1 NSUserdefaults
It is mainly used to store short information, such as application settings, attributes, and user data.
2. attribute list
Store data on a disk in the form of a list. The attribute list class includes NSArray, NSDictionary, NSString, NSNumber, NSDate, and NSdata.
These types of data can be stored to the disk and read from the disk by directly calling writeToFile and corresponding loading functions.
The corresponding loading functions include:
ArrayWithContentsOfFile:
DictionaryWithContentsOfFile:
StringWithContentsOfFile:
DataWithContentsOfFile:
NSdate and NSNumber can be stored after being replaced with NSString.
3. Object Archiving
For data that cannot be simply represented by attribute lists, object archive is used for storage.
Using NSCopying and implementing two functions: encodeWithCoder and initWithCoder, you can replace this type of object
NSData, and then use the 2nd method to store and read data.
4 CoreData
A persistence tool provided by Apple. To use this method, first we need to create a data model, and then we can easily
To store and read objects, and all others are handed over to the system.

Related Article

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.