zoukankan      html  css  js  c++  java
  • 查找文件的路径

    修改老代码时发现,发现这行代码

    NSString *filePath = [NSString documentsPath:@"CertificateType.plist"];
    NSArray *array = [NSArray arrayWithContentsOfFile:filePath];

    在真机没问题,而模拟器上报错:

    文件路径如下:

    这是因为在模拟器上filePath没有返回文件路径,所以array是空值,因此必须更改查找文件路径的方式:

    https://www.jianshu.com/p/a4935e6427ec

    根据文章重新修改获取路径,那么无论是模拟器还是真机 array 都会有值 

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"CertificateType" ofType:@"plist"];
                
    NSArray *array = [NSArray arrayWithContentsOfFile:filePath];
    
  • 相关阅读:
    haproxy 基于 cookie 的会话保持
    haproxy 透明代理
    haproxy tcp keepalive
    haproxy 支持 websocket
    python 中给文件加锁
    使用python生成二维码
    python中的uuid简介
    django建表报错
    pip安装第三方包PIL失败
    python获取mac地址的方法
  • 原文地址:https://www.cnblogs.com/QM80/p/10299624.html
Copyright © 2011-2022 走看看