使用NSBundle加载我的资源 [英] Using NSBundle to load my resources
问题描述
我想将我的资源,nib文件和本地化文件分成一个通用的可重用捆绑包。所以我为我的ios应用程序创建了一个包,并使用构建阶段,复制包资源指定要包含在包中的资源。但是,现在如果我尝试加载捆绑包,我无法加载捆绑包。我尝试使用[NSBundle allBundles],数组只显示主应用程序包。
I wanted to separate my resources, nib files and localization files into a common reusable bundle. And so I created a bundle for my ios application and specified resources to be included inside the bundle using build phases, copy bundle resources. But, now if I try to load the bundle, I am not able to load the bundle. I try using [NSBundle allBundles] and the array shows only the main apps bundle.
我还尝试枚举NSApplicationPath的目录,但是唯一可用的包是我的应用程序默认捆绑。我想学习这种技术并利用它来分离我的资源。任何帮助和建议将不胜感激。谢谢
I also tried to enumerate the directory for NSApplicationPath but again the only bundle available is my application default bundle. I wanted to learn this technique and make use of it to separate my resources. Any help and suggestions would be greatly appreciated. Thank you
推荐答案
[NSBundle bundleWithPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] bundlePath], pathToYourBundleWithinTheDotAppDirectory];
让我知道你是怎么过的。
Let me know how you get on.
这篇关于使用NSBundle加载我的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!