-[NSBundle pathForResource:Type:inDirectory:]为本地化资源返回nil



我有这样一个束结构:

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"]

它总是返回零。我的错误在哪里?我该怎么修?P.S."地图集"文件夹被添加为文件夹参考,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

最新更新