可加载的plists包

时间:2011-05-16 18:22:10

标签: iphone ios bundle nsbundle

我在主项目中有一个主项目和一个静态库项目。我的静态库项目中只需要很少的plists。由于没有资源目录,因此无法直接添加plist,这是做什么的。

1.为我的静态库项目添加了一个可加载的包 2.为可装载的捆绑添加了几个plist 3.这个可加载的包是作为我的静态库项目的依赖项 4.将此可加载包添加为我的主项目依赖

我正走在正确的道路上吗?当我解雇构建并使用显示内容来查看应用程序的内容时,我能够在.app文件中看到.bundle文件。现在我想知道如何访问此捆绑包。

我用过这个

NSBundle *staticlink = [NSBundle mainBundle] pathForResource:@"MyBundle" ofType:@"bundle"];
[staticlink load];
NSLog(@"%@",staticlink);

控制台说这个。

 . . . /mainproject.app/MyBundle.bundle <not yet loaded>

缺少什么?我应该怎么做加载MyBundle?

1 个答案:

答案 0 :(得分:2)

-pathFoResource:ofType:返回一个NSString对象,该对象将包含该包的路径。

NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"MyBundle" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
[bundle load];