Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在静态库项目中获取资源路径_Ios_Objective C_Xcode_Resources_Static Libraries - Fatal编程技术网

Ios 如何在静态库项目中获取资源路径

Ios 如何在静态库项目中获取资源路径,ios,objective-c,xcode,resources,static-libraries,Ios,Objective C,Xcode,Resources,Static Libraries,我在我的库项目中使用第三方SDK,SDK包含一个json文件。我需要在库项目类的一个方法中获取json文件的路径。该方法是从我的应用程序调用的(在库项目添加到我的应用程序之后)。 我正在使用10.10(OSX优胜美地)、iOS8.1、xcode 6.1环境。谢谢。使用NSBundle的pathForResource:ofType:方法。您还需要确保使用正确的bundle实例化NSBundle对象,否则将得到nil返回值。即[NSBundle mainBundle]将允许您浏览主应用程序捆绑包,但

我在我的库项目中使用第三方SDK,SDK包含一个json文件。我需要在库项目类的一个方法中获取json文件的路径。该方法是从我的应用程序调用的(在库项目添加到我的应用程序之后)。
我正在使用10.10(OSX优胜美地)、iOS8.1、xcode 6.1环境。谢谢。

使用
NSBundle
pathForResource:ofType:
方法。您还需要确保使用正确的bundle实例化
NSBundle
对象,否则将得到
nil
返回值。即
[NSBundle mainBundle]
将允许您浏览主应用程序捆绑包,但框架是独立的捆绑包


我倾向于使用
[NSBundle bundleForClass:[Obj class]][NSBundle bundleForClass:[UIView class]]

到目前为止您尝试了什么?我将该json文件添加到库项目的“正在构建阶段=>CopyFiles”,但我得到的路径是空值。您找到解决方案了吗?