[Cocoa] two places in IOS that permanently Save User Data

Source: Internet
Author: User

Permanent saving of user settings and Data

Luo chaohui (http://www.cnblogs.com/kesalin)

This article follows the "signature-non-commercial use-consistency" creation public agreement

 

To save user data or settings permanently, it is not affected by the re-installation of APP updates. We can only save this write data in the userdefaults or documents directory, these two locations have been explicitly supported in the official documentation.

 

For example:

<Application_home>/Documents/

all applications Program write data files to this directory. This directory is used to store user data or other information that should be regularly backed up. For information about how to obtain this directory path, see " Get application directory path " section.

iTunes backs up the contents of this directory.

/library/preferences

This directory contains the preference setting file of the application. Instead of directly creating preference files, you should use nsuserdefaults class or cfpreferences API to obtain and set application preferences, for more information, see " add settings Collation package " section.

iTunes backs up the contents of this directory.

Here, the documents directory can be used as follows:CodeObtain:

Nsstring* Localpaths =Nshomedirectory();

Localpaths = [localpathsStringbyappendingpathcomponent:@ "Documents"];

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.