你的位置:首页 > 软件开发 > 操作系统 > sandBoxPathFile

sandBoxPathFile

发布时间:2015-04-22 23:03:41
//获得本应用程序的沙盒目录 NSArray *array=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path= ...

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

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

 


原标题:sandBoxPathFile

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录