iOS [[NSBundle mainBundle] pathForResource:@"" ofType:@""]无法获取到文件

将一个文件导入到工程中后,用[[NSBundle mainBundle] pathForResource:@"" ofType:@""]来获取到该文件时,一直无法拿到这个文件,解决方法如下

在Build Phases -> Copy Bundle Resources下点击加号(+)

选择刚刚添加进工程的文件,店家add

这样就可以用[[NSBundle mainBundle] pathForResource:@"" ofType:@""]方法获取到这个文件了

原文地址:https://www.cnblogs.com/czq1989/p/5312146.html