首页 > 移动平台 > 详细

iOS文件操作

时间:2015-06-26 19:28:22      阅读:168      评论:0      收藏:0      [点我收藏+]
  //找到Documents文件所在的路径
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    //取得第一个Documents文件夹的路径
    
    NSString *filePath = [path objectAtIndex:0];
    
   
    
    NSString *plistPath = [filePath stringByAppendingPathComponent:@"collectionData.plist"];

    //存入(沙盒)
    [data writeToFile:plistPath atomically:YES];
    //读取(沙盒)
    NSArray *arr1 = [NSArray arrayWithContentsOfFile:plistPath];
     NSLog(@"%@",plistPath);
    NSLog(@"%@",arr1);
    
    NSString *bundlePath = [[NSBundle mainBundle]pathForResource:@"collectionData" ofType:@"plist"];
    NSLog(@"%@",bundlePath);
    //读取(Bundle)
    NSArray *arr2 = [NSArray arrayWithContentsOfFile:bundlePath];
    NSLog(@"---------%ld",arr2.count);

 

iOS文件操作

原文:http://www.cnblogs.com/hxwj/p/4602892.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!