File System

File System Basic

About the iOS File System

1.  During installation of a new app, the installer code creates a home directory for the app, places the app in that directory, and creates several other key directories. These directories constitute the app’s primary view of the file system.


2. 通常app被限制只能在sandbox中创建或访问文件。有一个例外是,当app使用public system接口时

3. When an app is installed on a device, iTunes creates a home directory for the app.当一个app被安装到设备上时,iTunes创建了一个home directory。

4. Application bundle directory (binary, .storyboards, .jpgs, etc.). This directory is NOT writeable.

    Documents directory. This is where you store permanent data created by the user.

    Caches directory. Store temporary files here (this is not backed up by iTunes).

    Other directories (check out NSSearchPathDirectory in the documentation).



Accessing Files and Directories

1.获取sandbox中目录地址

- (NSString *)stringByAppendingPathComponent:(NSString *)component;
- (NSString *)stringByDeletingLastPathComponent;

- (NSArray *)URLsForDirectory:(NSSearchPathDirectory)directory // see below
inDomains:(NSSearchPathDomainMask)domainMask; //NSUserDomainMask

NSSearchPathDirectory {
NSDocumentsDirectory,
NSCachesDirectory, 
NSAutosavedInformationDirectory
}


2. Provides utility operations (reading and writing is done via NSData, et. al.).
Check to see if files exist; create and enumerate directories; move, copy, delete files; etc. Just alloc/init an instance and start performing operations.
Thread safe (as long as a given instance is only ever used in one thread).


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值