首页 > 其他 > 详细

iPhone的沙盒目录

时间:2016-06-15 15:40:11      阅读:173      评论:0      收藏:0      [点我收藏+]

首先扫盲

1:Documents:应用中用户数据可以放在这里,iTunes备份和恢复的时候会包括此目录
2:tmp:存放临时文件,iTunes不会备份和恢复此目录,此目录下文件可能会在应用退出后删除
3:Library/Caches:存放缓存文件,iTunes不会备份此目录,此目录下文件不会在应用退出删除

路径获取代码:

//获取根目录 
        NSString *homePath = NSHomeDirectory(); 
        NSLog(@"Home目录:%@",homePath); 
  
        //获取Documents文件夹目录,第一个参数是说明获取Doucments文件夹目录,第二个参数说明是在当前应用沙盒中获取,所有应用沙盒目录组成一个数组结构的数据存放 
        NSArray *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
        NSString *documentsPath = [docPath objectAtIndex:0]; 
        NSLog(@"Documents目录:%@",documentsPath); 
  
        //获取Cache目录 
        NSArray *cacPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 
        NSString *cachePath = [cacPath objectAtIndex:0]; 
        NSLog(@"Cache目录:%@",cachePath); 
  
        //Library目录 
        NSArray *libsPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); 
        NSString *libPath = [libsPath objectAtIndex:0]; 
        NSLog(@"Library目录:%@",libPath); 
  
        //temp目录 
        NSString *tempPath = NSTemporaryDirectory(); 
        NSLog(@"temp目录:%@",tempPath);

 

iPhone的沙盒目录

原文:http://www.cnblogs.com/struggle3g/p/5587642.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!