![](/img/trans.png)
[英]NSBundle pathForResource:ofType: occasionally returns nil for one resource
[英]-[NSBundle pathForResource:ofType:inDirectory:] returns nil for localized resources
我有这样的捆绑结构:
bundle's root
------atlases
------------en.lproj
--------------------test-hd.plist
------------es.lproj
--------------------test-hd.plist
但是当我尝试使用此代码获取test-hd.plist用于当前本地化时
[[NSBundle mainBundle] pathForResource:@"test-hd.plist" ofType:nil inDirectory:@"atlases"]
它总是返回nil。 我的错误在哪里? 我该如何解决? PS“ atlases”文件夹已添加为文件夹参考,并且test-hd.plist始终可通过直线路径[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"atlases/en.lproj/test-hd.plist"]
您的目录结构错误。 en.lproj
等,应包含一个称为目录atlases
,就像这样:
<bundle root>
|-- en.lproj
|---- atlases
|------ test-hd.plist
|-- es.lproj
|---- atlases
\------ test-hd.plist
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.