zoukankan      html  css  js  c++  java
  • iOS开发之JSON转PLIST(把存储json格式的文件转换成plist文件)

    有时开发过程中,经常需要调试接口,但是可能经常没有网络,导致调试无法正常进行。

     

    对此可以自己手动设置一些假数据,也可以通过计算机来为我们保存一份真实的网络数据,并自己转化成plist数据,存在本地使用。

     

     

     

    ## 直接在Mac上运行

    ```objc

     

    NSString *path = @"/Users/xiaoyou/Desktop/lot.json";  

    NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil];  

    [array writeToFile:@"/Users/xiaoyou/Desktop/lot.plist" atomically:YES]; 

       

       

    ```

     

    ## 直接在模拟器上运行

     

     

    ```objc

    NSString *path = [[NSBundle mainBundle] pathForResource:@"lot.json" ofType:nil];  

      

    NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil];  

      

    NSString *newPath = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] bundlePath],@"/lot.plist" ];  

      

    [array writeToFile:newPath atomically:YES];  

     

    ```

     

     

  • 相关阅读:
    合并链表
    ImportError: cannot import name 'GMM' from 'sklearn.mixture'
    SyntaxError: invalid character in identifier
    在 jupyter notebook 中插入图片
    Atom 换行后删除前面空格,需要按2/4次退格键
    win10输入法InpuMode默认显示中文
    Visual Studio(WindowsSDK.targets(46,5): error MSB8036: 找不到 Windows SDK 版本8.1)
    atom修改注释的字体,字号,颜色
    '__int64' has not been declared
    VMware 打开虚拟机库
  • 原文地址:https://www.cnblogs.com/xiaoyouPrince/p/7119168.html
Copyright © 2011-2022 走看看