pathForResources返回(null)

时间:2011-07-06 19:18:38

标签: path null nsstring bundle nslog

我正在使用这些代码行

NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"test"];
 NSLog(@"%@", path);

NSLog正在打印(null)。

我正在尝试阅读的文件是index.html。它位于我的项目文件夹中的测试文件夹中。有谁知道为什么路径返回(null)。

由于

克林顿

1 个答案:

答案 0 :(得分:0)

如果找不到您的资源,此方法将返回nil。尝试另一个像-(NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension inDirectory:(NSString *)subpath指定'test'作为目录名。

另外,请确保您的文件已包含在您的应用套装中...