iOS文件操作

  //找到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);

 

posted @ 2015-06-26 17:44  幻想无极  阅读(166)  评论(0编辑  收藏  举报