关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
来源:互联网 发布:springmvc返回json 编辑:程序博客网 时间:2024/05/21 08:56
最近在使用[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]时,找不到其对应的文件,文件当时是通过 右键->add files to 的方式添加到工程里面的,但是使用[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]时,无论如何都找不到文件,经过了重启工程 、clear工程以及重启电脑等方式都无法解决问题。经过思考和测试,感觉这可能是xcode的一个bug.
解决办法及原理是这样的,[NSBundle mainBundle]其获取的路径是你程序的安装路径下的资源文件位置。 在xcode中采用add file to 方式添加文件时,一般情况下xcode会自动将文件添加到你的资源文件,而且,这些文件在你工程的 build Phases中的 copy Bundle Resources中可以查看到。但是有时候,由于xcode的问题,采用add files to 不能自动添加到你的资源文件中,这时,可以采用copy Bundle Resources下面的“+”号,手动将文件添加到你的资源文件中,这样就可以解决问题了。
http://blog.csdn.net/yangxuanlun/article/details/8938148
0 0
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- [[NSBundle mainBundle]pathForResource:@"name" ofType:@"type"] 获取不到本地文件
- [[NSBundle mainBundle]pathForResource:@"XXX" ofType:@"db"]为nil的解决办法
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- NSBundle mainBundle] pathForResource 返回nil的解决办法
- iOS开发中 [[NSBundle mainBundle] pathForResource: ofType:]路径为空的问题
- iOS问题笔记-[[NSBundle mainBundle] pathForResource: ofType:]方法获取不到资源路径
- [[NSBundle mainBundle]pathForResource..取值为空
- [[NSBundle mainBundle]pathForResource..取值为空
- NSBundle MainBundle的路径
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发 [NSBundle mainBundle] 通过pathForResource返回路径为空.
- 第八章:在Spark集群上掌握比较重要的图操作之Property Operators(2)
- 使用 cloc 统计代码行数
- 算法导论2-1-1
- day02--常用算法--查找
- Proftpd遇到的坑
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 数据库备份
- 美团技术团队 Quartz应用与集群原理分析
- Android中Settings.System的使用(系统全局变量)
- GRE写作必备句型
- 第九章:在Spark集群上掌握比较重要的图操作之Structural Operators
- App缓存管理
- spring中@Component注解
- 主窗体设计