zoukankan      html  css  js  c++  java
  • 3.4-文件操作

    一项目文件

      1保存项目文件:拖文件

      2读取项目文件,需要使用NSBundle对象

      

            //获取plist文件路径
            NSString *filePath = [[NSBundle mainBundle] pathForResource:@"tom.plist" ofType:nil];
            //用字典读取plist数据
            _tomData = [NSDictionary dictionaryWithContentsOfFile:filePath];
    

       

    二沙盒文件

      1保存沙盒文件

        

        // 获得douments文件夹
        NSString *doc = [ NSHomeDirectory()  stringByAppendingPathComponent:@"Documents"];
        // 获得保存数据的文件路径
        NSString *filePath = [doc stringByAppendingPathComponent:@"abc"];
        NSDictionary *data = @{@"name":@"jack",@"age":@100,@"height":@1.7};
        // 只要能够调用writeToFile方法的对象,都能够保存plist文件中。
        // NSString/NSData/NSNumber/NSDictionary/NSArray
        [@"1111" writeToFile:filePath atomically:YES];
    

     

      2读取沙盒文件

      

        // 获得保存数据的文件路径
        NSString *filePath = [doc stringByAppendingPathComponent:@"abc.plist"];
        NSDictionary *dict =[NSDictionary dictionaryWithContentsOfFile:filePath];
    

      

      

  • 相关阅读:
    HTTP
    jQuery
    BOM与DOM
    Page类成员
    Web用户自定义控件
    ASP.NET服务端基本控件介绍
    ASP.NET中的验证控件
    ASP.NET数据绑定控件
    ASP.NET中的母版页
    ASP.NET缓存 Cache
  • 原文地址:https://www.cnblogs.com/dzq1991/p/6246998.html
Copyright © 2011-2022 走看看