I saw quite a few questions regarding [NSBundle MainBundle] pathForResource
(using inDirectory or not), but my case seems different.
My problem is: Yes, it works fine for whatever files in subdirectory if without localization. For example, it returns the correct path for the file data/a/words.txt
when I use
[[NSBundle mainBundle] pathForResource:@"words.txt" ofType:nil inDirectory:@"data/a"]
However, after I localized the words.txt
, let's say the real path becomes: data/a/en.lproj/words.txt
, then the above code cannot find the path anymore.
I checked the file in the .app package and the file has been copied into the correct path (data/a/en.lproj)
, it's just somehow the code cannot find it.
I'm using XCode 5.1.1
Isn't pathForResource
supposed to find the text automatically?
Try adding
forLocalization
topathForResource
, like this: