zoukankan      html  css  js  c++  java
  • IOS中APP沙盒(sandbox)目录的路径详解

    NSString *path = NSHomeDirectory();
    上面的代码得到的是应用程序目录的路径,在该目录下有三个文件夹:Documents、Library、temp以及一个.app包!
    该目录下就是应用程序的沙盒,应用程序只能访问该目录下的文件夹!!!

    请参考下面的例子:
    1、
    NSString *path1 = NSHomeDirectory();

    NSLog(@"path1:%@", path1);
    path1:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830
    2、
    NSString *path2 = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];

    NSLog(@"path2:%@", path2);
    path2:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830/Library/Caches
    3、
    NSString *path3 = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

    NSLog(@"path3:%@", path3);
    path3:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830/Documents
    4、
    NSString *path4 = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

    NSLog(@"path4:%@", path4);
    path4:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830/Documents
    5、
    NSString *path5 = [NSHomeDirectory() stringByAppendingPathComponent:@"Library"];

    NSLog(@"path5:%@", path5);
    path5:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830/Library
    6、
    NSString *path6 = [NSHomeDirectory() stringByAppendingPathComponent:@"temp"];

    NSLog(@"path6:%@", path6);
    path6:/Users/yuanjun/Library/Application Support/iPhone Simulator/4.2/Applications/172DB70A-145B-4575-A31E-D501AC6EA830/temp

  • 相关阅读:
    idp账号使用系列记录
    cocos2dxjs binding安卓运行时出现signal 11 (SIGSEGV) 程序闪退问题记录
    cocos2dx 2.1.1 javascript在mac下跨平台编译粗略记录
    cocos2dx2.1使用Xcode整合ios与android开发代码 过程记录
    查找第k个数字的位置
    准备编写ogl2dlib的动画脚本编辑器
    开始学习nebula2 sdk
    地铁尴尬事件
    坦克物理模型(ode)
    MBTI职业性格测试(Psytopic特别版)
  • 原文地址:https://www.cnblogs.com/yingkong1987/p/2971336.html
Copyright © 2011-2022 走看看