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];

  • 相关阅读:
    Context对象还提供了相应的属性来调整线条及填充风格
    基本类型互相之间转化可以用Covent类来实现。
    chfn是用来改变你的finger讯息
    在Web根目录下建立testdb.php文件内容
    springmvc接口接收json类型参数设置
    表单类型参数样板
    git push 免密码
    git提交之后没有push,代码被覆盖之后恢复
    测试流程总结
    linux 更改时区
  • 原文地址:https://www.cnblogs.com/lucan727/p/3883680.html
Copyright © 2011-2022 走看看