IOS four ways to store data

Source: Internet
Author: User

    • nskeyedarchiver: Saves data in an archived form, which is subject to the nscoding protocol, and the class that corresponds to the object must provide Encodewithcoder: and Initwithcoder: methods. The previous method tells the system how to encode the object, and the latter method tells the system how to decode the object. For example , save the Possession object archive.
    • nsuserdefaults: Used to save application settings and properties, user-saved number nsuserdefaultsnsdatansstring nsnumber Nsdatensarraynsdictionary nsuserdefaults storage.
  • write writing mode: permanently saved on disk. The method is: The first step: Get the path of the file is about to save: nsarray *documentpaths =  Nssearchpathfordirectoriesindomains (Nsdocumentdirectory,  nsuserdomainmask,yes);//c function nssearchpathfordirectoriesindomains To get the full path of the sandbox catalog  he domain masknssearchpathdirectory iosnsuserdomainmask  yesnsstring *ourdocumentpath =[documentpaths objectatindex:0]; 

 

  •  sqlite: Use sqlite database to store data. sqlite as a small and medium-sized database, the application of ios   first step: Need to add sqlite related libraries and header files: build phaseslink binary library (ies) libsqlite3.0.dylib (libsqlite3.dylib< span class= "S2" > The difference between the former is not known, the two should be similar); Add a header file to the header file or source file in the project file #import   "/usr/include/sqlite3.h" span class= "S2" > Step two: start using sqlite: NOTE: If you do not add any tables to the database, this database is not created and will not generate any files on the hard disk , if the database already exists, the database will open. &NBSP;

IOS four ways to store data

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.