Common ways for iOS app data storage ios7.1 application sandbox

Source: Internet
Author: User

Archive: Saves an object in a format, also known as persistence.

1XML attribute List plist Archive (persistent)

2Preference (preference setting)

3NSKeyedArchiver Archiving

4sqlite3

5Core Data (manipulating SQLLite3)

Apply Sandbox

One, iOS sandbox mechanism

iOS apps can only access areas created for the app, inaccessible to other areas, and other non-code files for the app are present in this directory, including pictures, properties files, plist,bundle,nib files, and so on, which is known as the Sandbox (sandbox).

    1. Each app has its own storage space, which is the sandbox
    2. Apps can only access their own sandbox, not other areas
    3. If the application requires file operations, the files must be stored in the sandbox, especially the database files, which can be accessed when operating on the computer, but if they are available on a real machine, the database files must be copied to the sandbox.

Second, open the sandbox path

1. If you do not know the sandbox path, you can print its path in your own app. ( own virtual machine Xcode6.2 ios7.1)

1 NSLog (@ " sandbox path:%@", Nshomedirectory ());

will get the printed result * is a letter or a number, that is, the path of the sandbox

1 ---£º £37.692 private Address Book [31250:1282190 ] Sandbox path:/users/zjj/library/developer/coresimulator/devices/7ce3fb7e-052b-4b1d-8783-beafb45a3558/ data/containers/data/application/15b4c992-a4c6-4005-BF76-077EA5BBE9FC

Path is:/users/zjj/library/developer/coresimulator/devices

2. Open Finder, select Go-Go to Folder (or select shortcut key command+shift+g) Enter the printed path

Third, directory structure

Sandbox by default there are three directory folders Documents,library,tmp and app files that can only be manipulated in the appropriate folder

    • AppName. The package directory for the app application. Because the application must be signed, the content in this directory cannot be modified at run time, or the application will not start.
      • documents/save important data files and user data files for your application. Data such as database files, or files that are browsed to the program. The directory is backed up when ITunes syncs.

      • Library: Default settings and status information for storage applications;
      • Library/cache: Saves the support files that are generated when the application is used and

cache files and log files are best placed in this directory as well. ITunes does not back up this directory when syncing.

      Library/preferences saves the application's preferences file (created when using the Nsuserdefaults class settings and should not be created manually).
    • TMP: Saves the temporary data required to run the app, and when the iphone restarts, it clears all files in that directory.

The location of the iphone simulator has changed in Xcode 6。 At the same time, as mentioned in iOS 8 release note, the sandbox structure of the app has changed, and it is now divided into three containers, bundle containers, data containers, and icloud containers. IOS 8 App Sandbox directory structure such as:

Common ways for iOS app data storage ios7.1 application sandbox

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.