zoukankan      html  css  js  c++  java
  • 接口请求数据 缓存本地 .plist 文件

    //奖获取的数组或者字典存入   financeArr 数据数组

    1。//本地保存

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

                //获取完整路径

                NSString *documentsDirectory = [paths objectAtIndex:0];

                NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@"Test.plist"];//这里就是你将要存储的沙盒路径(.plist文件,名字自定义)

                [financeArr writeToFile:plistPath atomically:YES];

    2。//取出缓存

    //获取路径

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

        NSString *filePath = [[sandboxpath objectAtIndex:0] stringByAppendingPathComponent:@"Test.plist"];

        //获取数据

        NSMutableArray *dataArr = [NSMutableArray arrayWithContentsOfFile:filePath];

    //dataArr就是得到缓存数据数组

    写的不好   有错误的地方望大家多多指点

  • 相关阅读:
    程序猿编程,软件设计都干什么?
    工作流——来龙去脉
    开发编码流程
    我的spring-boot开发环境
    JSR 303
    项目中java异常处理
    学习交流,一些数据结构和算法实现!
    C运算符
    js锚点
    玻璃工艺学笔记
  • 原文地址:https://www.cnblogs.com/Lovexiaohuzi/p/7797366.html
Copyright © 2011-2022 走看看