解决pathForResource返回nil, 无法读取plist文件问题

有很多人在设置plist文件的时候, 会发现读取不了plist文件里面的内容, 返回值为nil, 下面我们来解决一下这个问题.

首先我们打开工程并且按照下面的步骤来设置:

设置好后, 我们来写一段代码测试一下看看是否添加好:

  1. NSBundle *bundle = [NSBundle mainBundle];  
  2. NSString *path = [bundle pathForResource:@"images" ofType:@"plist"];  
  3. _imageData = [NSMutableArray arrayWithContentsOfFile:path];  
  4. NSLog(@"%@", _imageData);  

读取后的数据图:

原文地址:https://www.cnblogs.com/lxlx1798/p/7091980.html