zoukankan      html  css  js  c++  java
  • sandBoxPathFile

     //获得本应用程序的沙盒目录

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

        NSString *path=[array objectAtIndex:0];

        NSLog(@"%@",path);

        

        //每个应用程序都有自己的沙盒目录,应用程序之间不能够相互访问沙盒目录

        //沙盒目录下具有Documents,Libray,temp

        //Documents目录下的文件会在itunes备份和恢复时一起备份到服务器和恢复到手机,程序中自己创建的文件需要放到Documents目录下

        //Libray存放的是系统的系统库,应用程序不能使用Libray目录

        //tmp目录存放临时文件,当从新启动时,会删除tmp目录下所有文件

        

        NSDictionary *dict=[[NSDictionary alloc]initWithObjectsAndKeys:@"a",@"b", nil];

        NSString *sandBoxPathFile=[NSString stringWithFormat:@"%@/abc.plist",path];

        //向本应用程序的沙盒目录的Documents文件下写入abc.plist

        [dict writeToFile:sandBoxPathFile atomically:YES];

        

        //读文件

        NSDictionary *readDict=[[NSDictionary alloc]initWithContentsOfFile:sandBoxPathFile];

        NSLog(@"%@",readDict);

  • 相关阅读:
    跳跃游戏
    不同路径
    最大子序和
    最长回文子序列
    最长公共子序列
    零钱兑换
    合并区间
    寻找数组的中心索引
    制造小程序中的一些经验
    h5写的一个签到积分系统
  • 原文地址:https://www.cnblogs.com/y16879w/p/4448663.html
Copyright © 2011-2022 走看看