zoukankan      html  css  js  c++  java
  • iOS沙盒

    iOS沙盒中一共有四个文件夹 

    ------安装目录(r)

          -------Ducuments:长期存放用户文件或文件夹(rw)

          -------A.pp:mainBundle:存放可执行文件和资源文件(r)

          -------tmp:存放临时文件(r,w) 

          -------Library 

             -------caches:存放缓存文件(rw)

    访问这些文件的方法:

    //获取根目录路径

        NSString *home=NSHomeDirectory();

        NSLog(@"%@",home);//打印出该路径

        //第一种:获取出Documents的路径的方法:字符串形式打印(再有根目录的路径为前     提)

        NSString *doc=[home stringByAppendingPathComponent:@"Documents"];

        NSLog(@"%@",doc);

      

          //第二种:获取出Documents的路径的方法:数组形式

     NSArray *path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

        NSLog(@"%@ ",path);

        //将Documents路径由数组形式变为字符串形式。

        NSString *path2=[path objectAtIndex:0];

        NSLog(@"%@",path2); 

       //获取出caches的路径 数组形式

    NSArray *pathc=NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

        NSLog(@"%@",pathcaches);

        //将caches路径由数组形式变为字符串形式。

        NSString *pathc2=[pathc objectAtIndex:0];

        NSLog(@" ::: %@  ",path3);

        

       //获取出tmp的路径

        NSString *pathtmp=NSTemporaryDirectory();

        NSLog(@"%@",pathtmp);

         //获取app中的testDab.bd文件的路径

        NSString *dbPath = [[NSBundle mainBundle]   pathForResource:@"testDaB" ofType:@"db"];

        NSLog(@"%@", dbPath);


         //将name这个字符串  写入到path0指定的文件中去。

        [name writeToFile:path0 atomically:YES encoding:NSUTF8StringEncoding error:nil];

  • 相关阅读:
    Android 创建Library Project(库项目)与引用操作
    Android插件化(二):使用DexClassLoader动态载入assets中的apk
    洛谷P3388 【模板】割点(割顶)(tarjan求割点)
    BZOJ 1179: [Apio2009]Atm(tarjan+SPFA)
    洛谷P1067 多项式输出(模拟)
    洛谷P2118 比例简化(暴力)
    BZOJ 3714: [PA2014]Kuglarz(最小生成树)
    BZOJ 4289: PA2012 Tax(最短路)
    BZOJ 4152: [AMPPZ2014]The Captain(最短路)
    洛谷P2939 [USACO09FEB]改造路Revamping Trails(最短路)
  • 原文地址:https://www.cnblogs.com/lucan727/p/3883680.html
Copyright © 2011-2022 走看看