App Sandbox

 
For security purposes, an iOS application has limited number of places where it can write its data. When an application is installed on a device, iTunes creates a home directory for the application. This directory represents the universe for that application and contains everything the application can access directly.

Directory

Description

<Application_Home>/AppName.app

This is the bundle directory containing the application itself. Do not write anything to this directory.

<Application_Home>/Documents/

Use this directory to store user documents and application data files. The contents of this directory can be made available to the user through file sharing.

The contents of this directory are backed up by iTunes.

<Application_Home>/Documents/Inbox

Use this directory to access files that your application was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your application in this directory; document interaction controllers may also place files in it.

Your application can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your application must silently move it out of the directory before making any changes.

The contents of this directory are backed up by iTunes.

<Application_Home>/Library/

This directory is the top-level directory for files that are not user data files. You typically put files in one of several standard subdirectories but you can also create custom subdirectories for files you want backed up but not exposed to the user. You should not use this directory for user data files.

The contents of this directory (with the exception of the Caches subdirectory) are backed up by iTunes.

<Application_Home>/tmp/

Use this directory to write temporary files that do not need to persist between launches of your application. Your application should remove files from this directory when it determines they are no longer needed. (The system may also purge lingering files from this directory when your application is not running.)

In iOS 2.1 and later, the contents of this directory are not backed up by iTunes.


The Library directory is where applications and other code modules store their custom data files. Regardless of whether you are writing code for iOS or Mac OS X, understanding the structure of the Library directory is important. You use this directory to store data files, caches, resources, preferences, and even user data in some specific situations. The Library directory itself contains several subdirectories that subdivide application-specific content into a few well-known categories. 

Directory

Usage

Caches

Use this directory to write any application-specific support files that your application can recreate easily. Your application is generally responsible for managing the contents of this directory and for adding and deleting files as needed.

In iOS 2.2 and later, the contents of this directory are not backed up by iTunes. In addition, iTunes removes files in this directory during a full restoration of the device.

Preferences

This directory contains application-specific preference files. You should not create files in this directory yourself. Instead, use the NSUserDefaultsclass or CFPreferences API to get and set preference values for your application.

In iOS, the contents of this directory are backed up by iTunes.


When you need to locate a file in one of the standard system directories, use the system frameworks to locate the directory first and then use the resulting URL to build a path to the file. The Foundation framework includes several options for locating the standard system directories:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值